diff --git a/bookwyrm/templatetags/status_display.py b/bookwyrm/templatetags/status_display.py index c92b1877a..5d1f86caf 100644 --- a/bookwyrm/templatetags/status_display.py +++ b/bookwyrm/templatetags/status_display.py @@ -1,6 +1,7 @@ """ template filters """ from dateutil.relativedelta import relativedelta from django import template +from django.conf import settings from django.contrib.humanize.templatetags.humanize import naturaltime, naturalday from django.template.loader import select_template from django.utils import timezone @@ -60,8 +61,8 @@ def get_published_date(date): delta = relativedelta(now, date) if delta.years: return naturalday(date) - if delta.days: - return naturalday(date, "M j") + if delta.days or delta.months: + return naturalday(date, settings.MONTH_DAY_FORMAT) return naturaltime(date) diff --git a/bookwyrm/tests/templatetags/test_status_display.py b/bookwyrm/tests/templatetags/test_status_display.py index 338c30481..de7d3ae2f 100644 --- a/bookwyrm/tests/templatetags/test_status_display.py +++ b/bookwyrm/tests/templatetags/test_status_display.py @@ -109,4 +109,17 @@ class StatusDisplayTags(TestCase): 2022, 1, 8, 0, 0, tzinfo=datetime.timezone.utc ) result = status_display.get_published_date(date) - self.assertEqual(result, "Jan 1") + self.assertEqual(result, "January 1") + + with patch("django.utils.timezone.now") as timezone_mock: + timezone_mock.return_value = datetime.datetime( + # bookwyrm-social#3365: bug with exact month deltas + 2022, + 3, + 1, + 0, + 0, + tzinfo=datetime.timezone.utc, + ) + result = status_display.get_published_date(date) + self.assertEqual(result, "January 1")