本文整理汇总了Python中twistedcaldav.timezones.TimezoneCache.register方法的典型用法代码示例。如果您正苦于以下问题:Python TimezoneCache.register方法的具体用法?Python TimezoneCache.register怎么用?Python TimezoneCache.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twistedcaldav.timezones.TimezoneCache
的用法示例。
在下文中一共展示了TimezoneCache.register方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_basic
# 需要导入模块: from twistedcaldav.timezones import TimezoneCache [as 别名]
# 或者: from twistedcaldav.timezones.TimezoneCache import register [as 别名]
def test_basic(self):
registerTzid("America/New_York", None)
registerTzid("US/Eastern", None)
tzcache = TimezoneCache()
tzcache.register()
self.assertTrue(tzcache.loadTimezone("America/New_York"))
self.assertTrue(tzcache.loadTimezone("US/Eastern"))
tzcache.unregister()
示例2: test_truncatedAprThenDecOK
# 需要导入模块: from twistedcaldav.timezones import TimezoneCache [as 别名]
# 或者: from twistedcaldav.timezones.TimezoneCache import register [as 别名]
def test_truncatedAprThenDecOK(self):
"""
Properties in components
"""
oldtzid = getTzid("America/New_York")
try:
registerTzid("America/New_York", None)
tzcache = TimezoneCache()
tzcache.register()
self.doTest(
"TruncatedApr01.ics",
datetime.datetime(2007, 04, 01, 16, 0, 0, tzinfo=utc),
datetime.datetime(2007, 04, 01, 17, 0, 0, tzinfo=utc),
)
示例3: test_not_in_cache
# 需要导入模块: from twistedcaldav.timezones import TimezoneCache [as 别名]
# 或者: from twistedcaldav.timezones.TimezoneCache import register [as 别名]
def test_not_in_cache(self):
tzcache = TimezoneCache()
tzcache.register()
data = """BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VTIMEZONE
TZID:US-Eastern
LAST-MODIFIED:19870101T000000Z
BEGIN:STANDARD
DTSTART:19671029T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
TZNAME:Eastern Standard Time (US & Canada)
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19870405T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=4
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
TZNAME:Eastern Daylight Time (US & Canada)
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:12345-67890
DTSTART;TZID="US-Eastern":20071225T000000
DTEND;TZID="US-Eastern":20071225T010000
ATTENDEE:mailto:[email protected]
ATTENDEE:mailto:[email protected]
END:VEVENT
END:VCALENDAR
"""
calendar = Component.fromString(data)
if calendar.name() != "VCALENDAR": self.fail("Calendar is not a VCALENDAR")
instances = calendar.expandTimeRanges(datetime.date(2100, 1, 1))
for key in instances:
instance = instances[key]
start = instance.start
end = instance.end
self.assertEqual(start, datetime.datetime(2007, 12, 25, 05, 0, 0, tzinfo=utc))
self.assertEqual(end, datetime.datetime(2007, 12, 25, 06, 0, 0, tzinfo=utc))