本文整理汇总了Python中datetime.datetime.__new__方法的典型用法代码示例。如果您正苦于以下问题:Python datetime.__new__方法的具体用法?Python datetime.__new__怎么用?Python datetime.__new__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datetime.datetime
的用法示例。
在下文中一共展示了datetime.__new__方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __new__
# 需要导入模块: from datetime import datetime [as 别名]
# 或者: from datetime.datetime import __new__ [as 别名]
def __new__(cls, value, trivia, raw): # type: (int, Trivia, str) -> Integer
return super(Integer, cls).__new__(cls, value)
示例2: __new__
# 需要导入模块: from datetime import datetime [as 别名]
# 或者: from datetime.datetime import __new__ [as 别名]
def __new__(cls, *args, **kwargs):
return datetime.__new__(datetime, *args, **kwargs)
示例3: __new__
# 需要导入模块: from datetime import datetime [as 别名]
# 或者: from datetime.datetime import __new__ [as 别名]
def __new__(cls, *args, **kwargs): # pylint: disable=signature-differs
return datetime.__new__(datetime, *args, **kwargs)
示例4: __new__
# 需要导入模块: from datetime import datetime [as 别名]
# 或者: from datetime.datetime import __new__ [as 别名]
def __new__(cls, *args, **kwargs):
return datetime.__new__(datetime, *args, **kwargs)
示例5: __new__
# 需要导入模块: from datetime import datetime [as 别名]
# 或者: from datetime.datetime import __new__ [as 别名]
def __new__(cls, month=1, day=1, hour=0, minute=0, leap_year=False):
"""Create Ladybug datetime.
"""
year = 2016 if leap_year else 2017
hour, minute = Time._calculate_hour_and_minute(hour + minute / 60.0)
try:
return datetime.__new__(cls, year, month, day, hour, minute)
except ValueError as e:
raise ValueError("{}:\n\t({}/{}@{}:{})(m/d@h:m)".format(
e, month, day, hour, minute
))
示例6: __reduce_ex__
# 需要导入模块: from datetime import datetime [as 别名]
# 或者: from datetime.datetime import __new__ [as 别名]
def __reduce_ex__(self, protocol):
"""Call the __new__() constructor when the class instance is unpickled.
This method is necessary for the pickle.loads() call to work.
"""
return (type(self), (self.month, self.day, self.hour, self.minute))