Parameter passing time formatting process

* Setting Import from 
Import datetime

sys.path.append (LIB_DIR)
# Print (LIB_DIR)


class TimeFormat:
'' 'time format' ''

DEF now_time (Self, the format):
'' '
Current Time
: param format: timestamp format
: return: return to the current time
'' '
the try:
return datetime.datetime.now () the strftime (the format).
the except Exception AS E:
return E

DEF n_days_later (Self, n, the format):
' ''
at time n days
: param n: number of days
: param format: timestamp format
: return: return time n days
' ''
the try:
. Time = (datetime.datetime.now () + the datetime.timedelta (Days = n)) the strftime (the format)
return Time
the except Exception AS E:
return E


: DEF n_hours_later (Self, n, the format)
'' '
after n hours time
: hours: n-param
: param the format:
: return:
'' '
the try:
. time = (datetime.datetime.now () + the datetime.timedelta (= n-hours)) the strftime (the format)
return time
the except Exception AS E:
return E

DEF n_minutes_later (Self, n, the format):
'' '
after n minutes
: param n: min
: param format:
:return:
'''
try:
time = (datetime.datetime.now() + datetime.timedelta(minutes=n)).strftime(format)
return time
except Exception as e:
return e

Guess you like

Origin www.cnblogs.com/jinbaobao/p/12028899.html