refactoring
changed ago.py
This commit is contained in:
parent
5c9ba685d2
commit
c4a62c9690
1 changed files with 3 additions and 6 deletions
9
ago.py
9
ago.py
|
|
@ -3,6 +3,8 @@ from datetime import (
|
|||
timedelta,
|
||||
)
|
||||
|
||||
units = ('year', 'day', 'hour', 'minute', 'second', 'microsecond')
|
||||
|
||||
def get_delta_from_subject(subject):
|
||||
subject_type = type(subject)
|
||||
if subject_type is timedelta:
|
||||
|
|
@ -42,17 +44,12 @@ def human(subject, precision=2, past_tense='{} ago', future_tense='in {}', abbre
|
|||
:returns: Human readable timedelta string (Str)
|
||||
"""
|
||||
delta = get_delta_from_subject(subject)
|
||||
|
||||
# determine if the_tense is past_tense or future_tense.
|
||||
the_tense = past_tense
|
||||
if delta < timedelta(0):
|
||||
the_tense = future_tense
|
||||
the_tense = future_tense if delta < timedelta(0) else past_tense
|
||||
|
||||
d = delta2dict( delta )
|
||||
|
||||
hlist = []
|
||||
count = 0
|
||||
units = ( 'year', 'day', 'hour', 'minute', 'second', 'microsecond' )
|
||||
|
||||
# start building up the output in the hlist.
|
||||
for unit in units:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue