Skip to content

Commit

Permalink
removed outdated formatting of date strings (#1830)
Browse files Browse the repository at this point in the history
* removed outdated formatting of date strings

* updated changelog
  • Loading branch information
matthewhegarty committed May 13, 2024
1 parent 31524a4 commit 7450393
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Changelog
- fix issue with widget assignment for custom ``ForeignKey`` subclasses (`1826 <https://github.com/django-import-export/django-import-export/pull/1826>`_)
- performance: select of valid pks for export restricted to action exports (`1827 <https://github.com/django-import-export/django-import-export/pull/1827>`_)
- fix crash on export with custom column name (`1828 <https://github.com/django-import-export/django-import-export/pull/1828>`_)
- remove outdated datetime formatting logic (`1830 <https://github.com/django-import-export/django-import-export/pull/1830>`_)

4.0.1 (2024-05-08)
------------------
Expand Down
9 changes: 3 additions & 6 deletions import_export/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@


def format_datetime(value, datetime_format):
# conditional logic to handle correct formatting of dates
# handle correct formatting of dates
# see https://code.djangoproject.com/ticket/32738
if django.VERSION[0] >= 4:
format = django.utils.formats.sanitize_strftime_format(datetime_format)
return value.strftime(format)
else:
return django.utils.datetime_safe.new_datetime(value).strftime(datetime_format)
format_ = django.utils.formats.sanitize_strftime_format(datetime_format)
return value.strftime(format_)


class Widget:
Expand Down

0 comments on commit 7450393

Please sign in to comment.