asciidoc.py 文件源码

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

项目:asciidoc3 作者: asciidoc 项目源码 文件源码
def date_time_str(t):
    """Convert seconds since the Epoch to formatted local date and time strings."""
    source_date_epoch = os.environ.get('SOURCE_DATE_EPOCH')
    if source_date_epoch is not None:
        t = time.gmtime(min(t, int(source_date_epoch)))
    else:
        t = time.localtime(t)
    date_str = time.strftime('%Y-%m-%d',t)
    time_str = time.strftime('%H:%M:%S',t)
    if source_date_epoch is not None:
        time_str += ' UTC'
    elif time.daylight and t.tm_isdst == 1:
        time_str += ' ' + time.tzname[1]
    else:
        time_str += ' ' + time.tzname[0]
    # Attempt to convert the localtime to the output encoding.
    try:
        time_str = char_encode(time_str.decode(locale.getdefaultlocale()[1]))
    except Exception:
        pass
    return date_str, time_str
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号