Opened 6 years ago

Closed 6 years ago

Last modified 4 years ago

#29600 closed Cleanup/optimization (fixed)

Remove usage of django.utils.datetime_safe where possible

Reported by: Tim Graham Owned by: Tim Graham
Component: Core (Other) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

django.utils.datetime_safe was added in #1443 to overcome limitations in Python 2.7 where strftime() doesn't support dates with year < 1900. That issue is fixed in Python 3, but an issue remains where the result of strftime('%Y') isn't consistent across all platforms. That issue was worked around in #12524.

strftime() and datetime_safe are no longer used in the JSON serializer as of 9b1cb755a28f020e27d4268c214b25315d4de42e but the fix from 03924929ba212368240bd7a26b14208fba965cb9 may still be useful in the other places that datetime_safe is used.

If we remove dateteime_safe usage in migrations (its need there is questionable, I think), that would fix #29595.

Change History (8)

comment:1 by Tim Graham, 6 years ago

Description: modified (diff)

comment:2 by GitHub <noreply@…>, 6 years ago

In 2ac7cd5:

Refs #29600 -- Removed datetime_safe usage in feedgenerator.

The only effect would be if items in Atom feeds had a published date
year of < 1000 (ensuring those years are padded with leading zeros).

comment:3 by Tim Graham <timograham@…>, 6 years ago

In 76852c39:

Refs #29600 -- Added test for datetime_safe usage in SelectDateWidget.value_from_datadict().

comment:4 by Tim Graham <timograham@…>, 6 years ago

In 013d439f:

Refs #29600 -- Added test for datetime_safe usage in localize_input().

comment:5 by Tim Graham <timograham@…>, 6 years ago

In c72dde41:

Fixed #29595 -- Allowed using timedelta in migrations questioner.

Refs #29600 -- Removed usage of django.utils.datetime_safe in migrations.

comment:6 by Tim Graham, 6 years ago

Resolution: fixed
Status: assignedclosed

I audited all usage of datetime_safe and added tests or removed usage as appropriate.

comment:7 by GitHub <noreply@…>, 6 years ago

In 2092206b:

Refs #29600 -- Updated django.utils.datetime_safe now that Python 2 is unsupported.

comment:8 by Carlton Gibson <carlton.gibson@…>, 4 years ago

In 44accb0:

Refs #32738, Refs #29600, Refs #29595 -- Removed unused django.utils.datetime_safe.time().

Unused since c72dde41e603093ab0bb12fa24fa69cfda0d35f9.

Note: See TracTickets for help on using tickets.
Back to Top