def timestampUNIX(value, is_local):
"""
Convert an UNIX (32-bit) timestamp to datetime object. Timestamp value
is the number of seconds since the 1st January 1970 at 00:00. Maximum
value is 2147483647: 19 january 2038 at 03:14:07.
May raise ValueError for invalid value: value have to be in 0..2147483647.
>>> timestampUNIX(0, False)
datetime.datetime(1970, 1, 1, 0, 0)
>>> timestampUNIX(1154175644.37, False)
datetime.datetime(2006, 7, 29, 12, 20, 44, 370000)
"""
timestamp = UNIX_TIMESTAMP_T0 + timedelta(seconds=value)
if is_local:
timestamp += LOCAL_TIMEZONE_OFFSET
return timestamp
评论列表
文章目录