Time.py 文件源码

python
阅读 38 收藏 0 点赞 0 评论 0

项目:rdiff-backup 作者: sol1 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号