当前位置: 首页>>代码示例>>Python>>正文


Python DateTime.localZone方法代码示例

本文整理汇总了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)
开发者ID:chitaranjan,项目名称:Uber-Food-Trucks,代码行数:9,代码来源:test_datetime.py

示例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)
开发者ID:,项目名称:,代码行数:16,代码来源:

示例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)
开发者ID:davidgillies,项目名称:silva.app.news,代码行数:16,代码来源:api.py

示例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())
开发者ID:tonibagur,项目名称:appy,代码行数:24,代码来源:date.py

示例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
开发者ID:eaudeweb,项目名称:naaya,代码行数:7,代码来源:NotificationTool.py


注:本文中的DateTime.DateTime.localZone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。