Skip to content

Commit

Permalink
Fix Widget is initialised with wrong date string for European locals #85
Browse files Browse the repository at this point in the history
  • Loading branch information
monim67 committed Nov 23, 2022
1 parent c0fa91f commit 7ac567d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/bootstrap_datepicker_plus/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class BasePickerInput(DateTimeBaseInput):
"""Base Date-Picker input class for widgets of this package."""

variant = WidgetVariant.date
_date_format = "%Y-%m-%d"
backend_date_format = "YYYY-MM-DD"
format_key = "DATE_INPUT_FORMATS"
options: Optional[WidgetOptions] = None
template_name = "bootstrap_datepicker_plus/input.html"

Expand Down Expand Up @@ -53,7 +53,7 @@ def __init__(
self.options,
options,
)
super().__init__(attrs)
super().__init__(attrs, self._date_format)

def build_attrs(
self, base_attrs: InputAttrs, extra_attrs: Optional[InputAttrs] = None
Expand Down
8 changes: 4 additions & 4 deletions src/bootstrap_datepicker_plus/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@ class TimePickerInput(BasePickerInput):
"""Widget to display a Time-Picker Calendar on a TimeField."""

variant = WidgetVariant.time
_date_format = "%H:%M:%S"
backend_date_format = "HH:mm:ss"
format_key = "TIME_INPUT_FORMATS"


class DateTimePickerInput(BasePickerInput):
"""Widget to display a DateTime-Picker Calendar on a DateTimeField."""

variant = WidgetVariant.datetime
_date_format = "%Y-%m-%d %H:%M:%S"
backend_date_format = "YYYY-MM-DD HH:mm:ss"
format_key = "DATETIME_INPUT_FORMATS"


class MonthPickerInput(BasePickerInput):
"""Widget to display a Month-Picker Calendar on a DateField."""

variant = WidgetVariant.month
_date_format = "%Y-%m-%d"
backend_date_format = "YYYY-MM-01"
format_key = "DATE_INPUT_FORMATS"


class YearPickerInput(BasePickerInput):
"""Widget to display a Year-Picker Calendar on a DateField."""

variant = WidgetVariant.year
_date_format = "%Y-%m-%d"
backend_date_format = "YYYY-01-01"
format_key = "DATE_INPUT_FORMATS"

0 comments on commit 7ac567d

Please sign in to comment.