本文整理汇总了Python中DateTime.DateTime.DateTime.tzoffset方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.tzoffset方法的具体用法?Python DateTime.tzoffset怎么用?Python DateTime.tzoffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTime.DateTime.DateTime
的用法示例。
在下文中一共展示了DateTime.tzoffset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_timezone_metadata
# 需要导入模块: from DateTime.DateTime import DateTime [as 别名]
# 或者: from DateTime.DateTime.DateTime import tzoffset [as 别名]
def test_timezone_metadata(self):
# http://www.zope.org/Collectors/CMF/325
# If an item's timestamp(s) are stored in another timezone,
# e.g. 4 hours further away from UTC, the DC date methods
# should still return it in the local timezone so that all
# user-visible dates can be compared to each other by eye.
site = DummySite('site').__of__(self.root)
item = self._makeDummyContent('item').__of__(site)
dates_and_methods = (
('modification_date', 'ModificationDate'),
('effective_date', 'EffectiveDate'),
('effective_date', 'Date'),
('expiration_date', 'ExpirationDate'),
('creation_date', 'CreationDate'))
offset = 4 # arbitrary, any value should work.
for datename, dc_methodname in dates_and_methods:
orig = getattr(item, datename)
# Some default to None, fix that.
if orig is None:
orig = DateTime()
setattr(item, datename, orig)
orig_DC = getattr(item, dc_methodname)()
# Change the timezone of the date.
local_offset = orig.tzoffset() % (3600*24)
other_offset = (local_offset + offset) % 24
otherzone = 'GMT+%d' % other_offset
setattr(item, datename, orig.toZone(otherzone))
# Finally, verify that display has not changed.
new_DC = getattr(item, dc_methodname)()
self.assertEqual(orig_DC, new_DC)