def readVTZ(tzid): """ Try to load the specified TZID as a calendar object from the database. Raise if not found. """ if tzid not in cachedVTZs: tzcal = TimezoneDatabase.getTimezoneInCalendar(tzid) if tzcal: cachedVTZs[tzid] = tzcal else: raise TimezoneException("Unknown time zone: %s" % (tzid, )) return cachedVTZs[tzid]
def test_getTimezoneInCalendar(self): """ L{TimezoneDatabase.getTimezoneInCalendar} returns correct result. """ data = ( ("America/New_York", True), ("America/Los_Angeles", True), ("America/Cupertino", True), ("America/FooBar", False), ) for tzid, result in data: cal = TimezoneDatabase.getTimezoneInCalendar(tzid) if result: self.assertTrue(cal is not None) self.assertEqual(cal.getComponents()[0].getID(), tzid) else: self.assertTrue(cal is None)