本文整理汇总了Python中DateTime.DateTime.localZone方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.localZone方法的具体用法?Python DateTime.localZone怎么用?Python DateTime.localZone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTime.DateTime
的用法示例。
在下文中一共展示了DateTime.localZone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testConstructor6
# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import localZone [as 别名]
def testConstructor6(self):
# Constructor from year and julian date
# This test must normalize the time zone, or it *will* break when
# DST changes!
dt1 = DateTime(2000, 5.500000578705)
dt = DateTime('2000/1/5 12:00:00.050 pm %s' % dt1.localZone())
self._compare(dt, dt1)
示例2: set
# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import localZone [as 别名]
def set(self, instance, value, **kwargs):
if not value:
value = None
elif not isinstance(value, DateTime):
try:
value = DateTime(value)
if value.timezoneNaive():
zone = value.localZone(safelocaltime(value.timeTime()))
parts = value.parts()[:-1] + (zone,)
value = DateTime(*parts)
except DateTimeError:
value = None
super(XSharedBuyablePeriodDateTimeField, self).set(
instance, value, **kwargs)
示例3: _toDateTime
# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import localZone [as 别名]
def _toDateTime(dt):
"""converts a Python datetime object to a localized Zope
DateTime one"""
if dt is None:
return None
if type(dt) in [str, unicode]:
# string
dt = DateTime(dt)
return dt.toZone(dt.localZone())
elif type(dt) == tuple:
# tuple
return DateTime(*dt)
# datetime?
return DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute)
示例4: getDateFromIndexValue
# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import localZone [as 别名]
def getDateFromIndexValue(indexValue):
'''p_indexValue is the internal representation of a date as stored in the
zope Date index (see "_convert" method in DateIndex.py in
Products.pluginIndexes/DateIndex). This function produces a DateTime
based on it.'''
# p_indexValue represents a number of minutes
minutes = indexValue % 60
indexValue = (indexValue-minutes) / 60 # The remaining part, in hours
# Get hours
hours = indexValue % 24
indexValue = (indexValue-hours) / 24 # The remaining part, in days
# Get days
day = indexValue % 31
if day == 0: day = 31
indexValue = (indexValue-day) / 31 # The remaining part, in months
# Get months
month = indexValue % 12
if month == 0: month = 12
year = (indexValue - month) / 12
from DateTime import DateTime
utcDate = DateTime('%d/%d/%d %d:%d UTC' % (year,month,day,hours,minutes))
return utcDate.toZone(utcDate.localZone())
示例5: DateTime_from_datetime
# 需要导入模块: from DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime import localZone [as 别名]
def DateTime_from_datetime(dt):
DT = DateTime(dt.isoformat())
zone = DT.localZone(dt.timetuple())
local_DT = DT.toZone(zone)
return local_DT