Skip to content

Commit

Permalink
Merge pull request #75 from rgs258/bugfix-test-self-format-correctly
Browse files Browse the repository at this point in the history
Corrects assignment of formats
  • Loading branch information
FlipperPA authored Aug 12, 2021
2 parents 972f6c4 + 7f8fcfe commit e88ac5b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tempus_dominus/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,17 @@ def moment_option(self, value):
"""
if isinstance(value, str):
if isinstance(self, DatePicker):
formats = [self.format] or get_format("DATE_INPUT_FORMATS")
formats = [self.format] if self.format else get_format(
"DATE_INPUT_FORMATS"
)
elif isinstance(self, TimePicker):
formats = [self.format] or get_format("TIME_INPUT_FORMATS")
formats = [self.format] if self.format else get_format(
"TIME_INPUT_FORMATS"
)
else:
formats = get_format("DATETIME_INPUT_FORMATS")
formats = [self.format] if self.format else get_format(
"DATETIME_INPUT_FORMATS"
)
for fmt in formats:
try:
value = datetime.strptime(value, fmt)
Expand Down

0 comments on commit e88ac5b

Please sign in to comment.