ver_2.py 文件源码

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

项目:dbf 作者: wenzhihong2003 项目源码 文件源码
def __new__(cls, year=None, month=0, day=0, hour=0, minute=0, second=0, microsecond=0):
        """year may be a datetime.datetime"""
        if year is None or year is Null:
            return cls._null_datetime
        ndt = object.__new__(cls)
        if isinstance(year, basestring):
            return DateTime.strptime(year)
        elif isinstance(year, (DateTime)):
            ndt._datetime = year._datetime
        elif isinstance(year, (datetime.datetime)):
            microsecond = year.microsecond // 1000 * 1000
            hour, minute, second = year.hour, year.minute, year.second
            year, month, day = year.year, year.month, year.day
            ndt._datetime = datetime.datetime(year, month, day, hour, minute, second, microsecond)
        elif year is not None:
            microsecond = microsecond // 1000 * 1000
            ndt._datetime = datetime.datetime(year, month, day, hour, minute, second, microsecond)
        return ndt
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号