Revert timesince chunks after monkey patch (fixes #181)

This commit is contained in:
Christopher C. Wells 2021-01-03 19:08:11 -08:00
parent b5086decd8
commit b009a0bebc
1 changed files with 4 additions and 1 deletions

View File

@ -6,13 +6,16 @@ from django.utils.translation import ngettext
def child_age_string(duration):
"""Monkey patch timesince function to day precision only.
"""
default_timesine_chunks = timesince.TIMESINCE_CHUNKS
timesince.TIMESINCE_CHUNKS = (
(60 * 60 * 24 * 365, 'year'),
(60 * 60 * 24 * 30, 'month'),
(60 * 60 * 24 * 7, 'week'),
(60 * 60 * 24, 'day'),
)
return timesince.timesince(duration)
ts = timesince.timesince(duration)
timesince.TIMESINCE_CHUNKS = default_timesine_chunks
return ts
def duration_string(duration, precision='s'):