Opened 15 years ago
Closed 15 years ago
#12261 closed (duplicate)
strftime function from django.utils.datetime_safe doesn't work properly in years below 1000
Description ¶
If a model has a DateTimeField attribute, in order to serialize the objects, django uses the format "%Y/%m/%d". However the function strftime
doesn't handle properly the option "%Y" in years below 1000: instead to fill with zeros (0) until to complete the 4 digits, it uses spaces. Therefore, at deserialization time django raises a exception.
Currently
>>> datetime_safe.date(850, 8, 2).strftime("%Y/%m/%d") ' 850/00/02'
It must to be
>>> datetime_safe.date(850, 8, 2).strftime("%Y/%m/%d") '0850/00/02'
The simplest patch is atached, but this issue can be deeper.
Change History (3)
by , 15 years ago
Attachment: | strftime_filling_with_zeros_years_below_1000.diff added |
---|
comment:1 by , 15 years ago
Needs tests: | set |
---|
Note:
See TracTickets
for help on using tickets.
strftime filling with zeros in years below 1000