o 3a @sddlZddlZddlmZddlmZmZddlmZm Z e dde dde d d e d d e d de dddZ dZ dddZ dddZ dS)N)avoid_wrapping)is_awareutc)gettext ngettext_lazyz%d yearz%d yearsz%d monthz %d monthsz%d weekz%d weeksz%d dayz%d daysz%d hourz%d hoursz %d minutez %d minutes)yearmonthweekdayhourminute))i3r)i'r)i: r )iQr )ir )<r FcCs|durt}|dkrtdt|tjst|j|j|j}|r0t|tjs0t|j|j|j}|p=tjt|r;t nd}|rE||}}||}t |j|j}|dkrjt |jr`|d8}n t |jrj|d7}|t |8}|jddd|j}|dkrt|ddSttD]\}\} } || } | dkrn qt|ddSg} d} |ttkr| |krt|\} } || } | dkrn#| t|| | || | 8}| d7} |d7}|ttkr| |kstd| S) a Take two datetime objects and return the time between d and now as a nicely formatted string, e.g. "10 minutes". If d occurs after now, return "0 minutes". Units used are years, months, weeks, days, hours, and minutes. Seconds and microseconds are ignored. Up to `depth` adjacent units will be displayed. For example, "2 weeks, 3 days" and "1 year, 3 months" are possible outputs, but "2 weeks, 3 hours" and "1 year, 5 days" are not. `time_strings` is an optional dict of strings to replace the default TIME_STRINGS dict. `depth` is an optional integer to control the number of adjacent time units returned. Adapted from https://web.archive.org/web/20060617175230/http://blog.natbat.co.uk/archive/2003/Jun/14/time_since Nrzdepth must be greater than 0.r r z, ) TIME_STRINGS ValueError isinstancedatetimerrr nowrrcalendarleapdaysisleap timedeltadayssecondsr enumerateTIMESINCE_CHUNKSlenappendrjoin)drreversed time_stringsdepthdeltarsinceirnamecountresult current_depthr,8/usr/lib/python3/dist-packages/django/utils/timesince.py timesincesR        r.cCst||d||dS)zV Like timesince, but return a string measuring the time until the given time. T)r"r#r$)r.)r!rr#r$r,r,r- timeuntilasr/)NFNr)NNr)rrdjango.utils.htmlrdjango.utils.timezonerrdjango.utils.translationrrrrr.r/r,r,r,r-s  F