Skip to content

Commit

Permalink
Merge pull request #761 from russellfinlay/master
Browse files Browse the repository at this point in the history
Add shorter format datetime-local defaults
  • Loading branch information
azmeuk committed Jan 13, 2023
2 parents 7418bac + d0a386d commit 22e766c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Unreleased

- Delayed import of ``email_validator``. :issue:`727`
- Python 3.11 support :pr:`763`
- Added shorter format to :class:`~fields.DateTimeLocalField`
defaults :pr:`761`

Version 3.0.1
-------------
Expand Down
10 changes: 9 additions & 1 deletion src/wtforms/fields/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,13 @@ class DateTimeLocalField(DateTimeField):
widget = widgets.DateTimeLocalInput()

def __init__(self, *args, **kwargs):
kwargs.setdefault("format", ["%Y-%m-%d %H:%M:%S", "%Y-%m-%dT%H:%M:%S"])
kwargs.setdefault(
"format",
[
"%Y-%m-%d %H:%M:%S",
"%Y-%m-%dT%H:%M:%S",
"%Y-%m-%d %H:%M",
"%Y-%m-%dT%H:%M",
],
)
super().__init__(*args, **kwargs)

0 comments on commit 22e766c

Please sign in to comment.