本文整理汇总了Python中DateTime.DateTime.DateTime.millis方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.millis方法的具体用法?Python DateTime.millis怎么用?Python DateTime.millis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTime.DateTime.DateTime
的用法示例。
在下文中一共展示了DateTime.millis方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _convertDateTime
# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import millis [as 别名]
def _convertDateTime( self, value ):
if value is None:
return value
if type( value ) == type( '' ):
dt_obj = DateTime( value )
value = dt_obj.millis() / 1000 / 60 # flatten to minutes
if isinstance( value, DateTime ):
value = value.millis() / 1000 / 60 # flatten to minutes
return int( value )
示例2: _convertDateTime
# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import millis [as 别名]
def _convertDateTime( self, value ):
if value is None:
return value
if type( value ) == type( '' ):
dt_obj = DateTime( value )
value = dt_obj.millis() / 1000 / 60 # flatten to minutes
if isinstance( value, DateTime ):
value = value.millis() / 1000 / 60 # flatten to minutes
result = int( value )
if isinstance(result, long): # this won't work (Python 2.3)
raise OverflowError( '%s is not within the range of dates allowed'
'by a DateRangeIndex' % value)
return result
示例3: _convertDateTime
# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import millis [as 别名]
def _convertDateTime(self, value):
if value is None:
return value
if isinstance(value, (str, datetime)):
dt_obj = DateTime(value)
value = dt_obj.millis() / 1000 / 60 # flatten to minutes
elif isinstance(value, DateTime):
value = value.millis() / 1000 / 60 # flatten to minutes
if value > MAX32 or value < -MAX32:
# t_val must be integer fitting in the 32bit range
raise OverflowError("%s is not within the range of dates allowed" "by a DateRangeIndex" % value)
value = int(value)
# handle values outside our specified range
if value > self.ceiling_value:
return None
elif value < self.floor_value:
return None
return value
示例4: datetime_to_minutes
# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import millis [as 别名]
def datetime_to_minutes(value, precision=1,
max_value=MAX32, min_value=-MAX32):
if value is None:
return value
if isinstance(value, (str, datetime)):
value = DateTime(value)
if isinstance(value, DateTime):
value = value.millis() / 1000 / 60 # flatten to minutes
# flatten to precision
if precision > 1:
value = value - (value % precision)
value = int(value)
if value > max_value or value < min_value:
# value must be integer fitting in the range (default 32bit)
raise OverflowError(
'{0} is not within the range of dates allowed.'.format(value))
return value