def gettzd(timeinseconds = None):
"""Return w3's timezone identification string.
Expresed as [+/-]hh:mm. For instance, PDT is -07:00 during
dayling savings and -08:00 otherwise. Zone coincides with what
localtime(), etc., use. If no argument given, use the current
time.
"""
if timeinseconds is None: timeinseconds = time.time()
dst_in_effect = time.daylight and time.localtime(timeinseconds)[8]
if dst_in_effect: offset = -time.altzone/60
else: offset = -time.timezone/60
if offset > 0: prefix = "+"
elif offset < 0: prefix = "-"
else: return "Z" # time is already in UTC
if Globals.use_compatible_timestamps: time_separator = '-'
else: time_separator = ':'
hours, minutes = map(abs, divmod(offset, 60))
assert 0 <= hours <= 23
assert 0 <= minutes <= 59
return "%s%02d%s%02d" % (prefix, hours, time_separator, minutes)
评论列表
文章目录