util.py 文件源码

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

项目:mobetta 作者: maykinmedia 项目源码 文件源码
def timestamp_for_metadata(dt=None):
    """
    Return a timestamp with a timezone for the configured locale.  If all else
    fails, consider localtime to be UTC.

    Originally written by Marco Bonetti.
    """
    dt = dt or datetime.datetime.now()
    if timezone is None:
        return dt.strftime('%Y-%m-%d %H:%M%z')
    if not dt.tzinfo:
        tz = timezone.get_current_timezone()
        if not tz:
            tz = timezone.utc
        dt = dt.replace(tzinfo=timezone.get_current_timezone())
    return dt.strftime("%Y-%m-%d %H:%M%z")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号