Viewing File: /opt/alt/python35/lib/python3.5/site-packages/humanize/__pycache__/time.cpython-35.opt-1.pyc



dT@sdZddlZddlmZmZmZddlmZmZdddd	gZ	d
dZ
dd
ZddZdddZ
ddddZdddZdd	ZdS)zZTime humanizing functions.  These are largely borrowed from Django's
``contrib.humanize``.N)datetime	timedeltadate)ngettextgettextnaturaldeltanaturaltime
naturaldaynaturaldatecCs
tjS)N)rnowr
r
/time.py_nowsrcCs(|jdkr$t}|||S|S)zUReturns an "absolute" value for a timedelta, always representing a
    time distance.r)daysr)deltarr
r
r
abs_timedeltas	rcCst}t|tr+|}||}npt|trM||}|}nNy)t|}td|}||}Wn"ttfk
rd|fSYnX|t|fS)zTurn a value into a date and a timedelta which represents how long ago
    it was.  If that's not possible, return (None, value).secondsN)r
isinstancerrint
ValueError	TypeErrorr)valuerrrr
r
rdate_and_deltas	

	rTcCst}t|\}}|dkr+|S|}t|j}t|j}|d}|d}t|d}|r|dkr|dkrtdS|dkrtdS|dkrtd	d
||Sd|kodknrtdSd|kod
knr2|d}	tdd|	|	Sd
|koId"knrXtdSd
|kr|d
}
tdd|
|
Sn|dkr|dkrtdS|stdd||S|stdd||S|dkrtdStdd||Sn|dkr|r,|r,tdS|sFtdd||S|ry|dkrbtdStdd||Sqtdd||Sntd d!||SdS)#a2Given a timedelta or a number of seconds, return a natural
    representation of the amount of time elapsed.  This is similar to
    ``naturaltime``, but does not add tense to the result.  If ``months``
    is True, then a number of months (based on 30.5 days) will be used
    for fuzziness between years.Nimg>@rrza momentza second<z	%d secondz
%d secondsxza minuteiz	%d minutez
%d minuteszan hourz%d hourz%d hoursza dayz%d dayz%d daysza monthz%d monthz	%d monthsza yearz1 year, %d dayz1 year, %d daysz1 year, 1 monthz1 year, %d monthz1 year, %d monthsz%d yearz%d yearsi )rrabsrrr_r)rmonthsrrrZ
use_monthsrrZyearsZminutesZhoursr
r
rr*sb	











FcCst}t|\}}|dkr+|St|ttfrL||k}|r^tdn	td}t||}|tdkrtdS||S)aGiven a datetime or a number of seconds, return a natural representation
    of that time in a resolution that makes sense.  This is more or less
    compatible with Django's ``naturaltime`` filter.  ``future`` is ignored for
    datetimes, where the tense is always figured out based on the current time.
    If an integer is passed, the return value will be past tense by default,
    unless ``future`` is set to True.Nz%s from nowz%s agoza momentr)rrrrrrr)rfuturerrrrZagor
r
rr	ks	
z%b %dcCsyt|j|j|j}Wn1tk
r7|SYnttfk
rR|SYnX|tj}|jdkr|t	dS|jdkrt	dS|jdkrt	dS|j
|S)zFor date values that are tomorrow, today or yesterday compared to
    present day returns representing string. Otherwise, returns a string
    formatted according to ``format``.rtodayrZtomorrowZ	yesterday)ryearmonthdayAttributeError
OverflowErrorrr!rrstrftime)rformatrr
r
rr
s
	


cCsyt|j|j|j}Wn1tk
r7|SYnttfk
rR|SYnXt|tj}|j	dkrt
|dSt
|S)zRLike naturalday, but will append a year for dates that are a year
    ago or more.imz%b %d %Y)rr#r$r%r&r'rrr!rr
)rrr
r
rrs
	
)__doc__timerrrZi18nrrr__all__rrrrr	r
rr
r
r
r<module>sA
Back to Directory File Manager