mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 00:26:33 +00:00
naturalday_partial: do not naturalize dates with missing parts
This commit is contained in:
parent
0e3936cb61
commit
0d908b594c
2 changed files with 9 additions and 1 deletions
|
@ -27,4 +27,6 @@ def naturalday_partial(date, arg=None):
|
|||
fmt = "YEAR_MONTH_FORMAT" if arg == "DATE_FORMAT" else arg
|
||||
else:
|
||||
fmt = "Y" if arg in django_formats else arg
|
||||
return naturalday(date, fmt)
|
||||
if date.has_day:
|
||||
return naturalday(date, fmt)
|
||||
return defaultfilters.date(date, fmt)
|
||||
|
|
|
@ -77,3 +77,9 @@ class PartialDateTags(TestCase):
|
|||
self.assertEqual("today", date_ext.naturalday_partial(today))
|
||||
self.assertEqual("today", date_ext.naturalday_partial(today_date))
|
||||
self.assertEqual("today", date_ext.naturalday_partial(today_exact))
|
||||
|
||||
# dates with missing parts can't
|
||||
today_year = YearParts.from_datetime(today)
|
||||
today_month = MonthParts.from_datetime(today)
|
||||
self.assertEqual(str(today.year), date_ext.naturalday_partial(today_year))
|
||||
self.assertEqual(str(today.year), date_ext.naturalday_partial(today_month, "Y"))
|
||||
|
|
Loading…
Reference in a new issue