diff --git a/CHANGES.md b/CHANGES.md index ff46d39..e574f0c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -71,6 +71,7 @@ * Fix update Soupsieve (05086ef) broke MC and TVC browse cards * Change move scantree to sg_helpers to prevent circular reference of it ever again * Update included fallback timezone info file to 2020c +* Change use natural time for age if now is night time and the last recent is yesterday evening, otherwise output age as 'yesterday' ### 0.22.11 (2020-10-30 01:45:00 UTC) diff --git a/gui/slick/interfaces/default/history.tmpl b/gui/slick/interfaces/default/history.tmpl index 7803e22..a743695 100644 --- a/gui/slick/interfaces/default/history.tmpl +++ b/gui/slick/interfaces/default/history.tmpl @@ -633,12 +633,15 @@ #set $last_rls_timedelta = ($SGDatetime.now() - $cur_provider.last_recent_search) #set $last_rls_age = $last_rls_timedelta.days #set $last_rls_age_str = '%s days ago' % $last_rls_age - #set $tmp = $humanize.naturalday(cur_provider.last_recent_search, format='', locale=False) + #set $tmp = $humanize.naturalday($cur_provider.last_recent_search, format='', locale=False) #if $tmp + #set $last_rls_age_str = $humanize.naturaltime($last_rls_timedelta) #if 'yesterday' == $tmp - #set $last_rls_age_str = $humanize.naturalday(cur_provider.last_recent_search) - #else - #set $last_rls_age_str = $humanize.naturaltime($last_rls_timedelta) + #set $is_now_night = 6 > $SGDatetime.now().hour + #set $is_last_evening = 18 <= $cur_provider.last_recent_search.hour + #if not ($is_now_night and $is_last_evening) + #set $last_rls_age_str = $humanize.naturalday($cur_provider.last_recent_search) + #end if #end if #end if #end if diff --git a/lib/humanize/time.py b/lib/humanize/time.py index a9292da..279604d 100644 --- a/lib/humanize/time.py +++ b/lib/humanize/time.py @@ -38,6 +38,11 @@ class Unit(Enum): return self.value < other.value return NotImplemented + def __gt__(self, other): + if self.__class__ is other.__class__: + return self.value > other.value + return NotImplemented + def __eq__(self, other): if self.__class__ is other.__class__: return self.value == other.value @@ -58,6 +63,9 @@ class Unit(Enum): return self.value != other.value return NotImplemented + def __hash__(self): + return hash(self.value) + def _now(): return dt.datetime.now()