Browse Source

Merge branch 'feature/ChangeAgeHumanize' into develop

tags/release_0.25.1
JackDandy 5 years ago
parent
commit
aa32b3edae
  1. 1
      CHANGES.md
  2. 11
      gui/slick/interfaces/default/history.tmpl
  3. 8
      lib/humanize/time.py

1
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)

11
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

8
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()

Loading…
Cancel
Save