opx_rel_pkgasm.py 文件源码

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

项目:opx-build 作者: open-switch 项目源码 文件源码
def art8601_format(dt):
    """
    Format datetime object in ISO 8601 format suitable for Artifactory.

    Artifactory's ISO 8601 timestamp parser is strict. It only accepts
    3 sigificant digits of sub-second precision (milliseconds) instead
    of the 6 significant digits (microseconds) in datetime.isoformat()
    output.

    I've raised a support ticket asking JFrog to consider relaxing
    their parser.

    Code adapted from standard python library.
    """

    s = '%04d-%02d-%02dT%02d:%02d:%02d.%03d' % (
        dt.year,
        dt.month,
        dt.day,
        dt.hour,
        dt.minute,
        dt.second,
        dt.microsecond / 1000)

    utc_offset = dt.utcoffset()
    if utc_offset is not None:
        if utc_offset.days < 0:
            sign = '-'
            utc_offset = - utc_offset
        else:
            sign = '+'

        hh, mm = divmod(utc_offset.seconds, 3600)
        mm //= 60

        s += "%s%02d%02d" % (sign, hh, mm)
    else:
        s += "Z"

    return s
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号