本文整理汇总了Python中pycalendar.icalendar.calendar.Calendar.getTimezone方法的典型用法代码示例。如果您正苦于以下问题:Python Calendar.getTimezone方法的具体用法?Python Calendar.getTimezone怎么用?Python Calendar.getTimezone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycalendar.icalendar.calendar.Calendar
的用法示例。
在下文中一共展示了Calendar.getTimezone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TimezoneDatabase
# 需要导入模块: from pycalendar.icalendar.calendar import Calendar [as 别名]
# 或者: from pycalendar.icalendar.calendar.Calendar import getTimezone [as 别名]
class TimezoneDatabase(object):
"""
On demand timezone database cache. This scans a TZdb directory for .ics files matching a
TZID and caches the component data in a calendar from whence the actual component is returned.
"""
sTimezoneDatabase = None
@staticmethod
def createTimezoneDatabase(dbpath):
TimezoneDatabase.sTimezoneDatabase = TimezoneDatabase()
TimezoneDatabase.sTimezoneDatabase.setPath(dbpath)
@staticmethod
def clearTimezoneDatabase():
if TimezoneDatabase.sTimezoneDatabase is not None:
TimezoneDatabase.sTimezoneDatabase.clear()
def __init__(self):
from pycalendar.icalendar.calendar import Calendar
self.dbpath = None
self.calendar = Calendar()
self.tzcache = {}
self.stdtzcache = set()
def setPath(self, dbpath):
self.dbpath = dbpath
def clear(self):
from pycalendar.icalendar.calendar import Calendar
self.calendar = Calendar()
self.tzcache.clear()
self.stdtzcache.clear()
@staticmethod
def getTimezoneDatabase():
if TimezoneDatabase.sTimezoneDatabase is None:
TimezoneDatabase.sTimezoneDatabase = TimezoneDatabase()
return TimezoneDatabase.sTimezoneDatabase
@staticmethod
def getTimezone(tzid):
return TimezoneDatabase.getTimezoneDatabase()._getTimezone(tzid)
@staticmethod
def getTimezoneInCalendar(tzid):
"""
Return a VTIMEZONE inside a valid VCALENDAR
"""
tz = TimezoneDatabase.getTimezone(tzid)
if tz is not None:
from pycalendar.icalendar.calendar import Calendar
cal = Calendar()
cal.addComponent(tz.duplicate(cal))
return cal
else:
return None
@staticmethod
def getTimezoneOffsetSeconds(tzid, dt, relative_to_utc=False):
# Cache it first
tz = TimezoneDatabase.getTimezone(tzid)
if tz is not None:
return tz.getTimezoneOffsetSeconds(dt, relative_to_utc)
else:
return 0
@staticmethod
def getTimezoneDescriptor(tzid, dt):
# Cache it first
tz = TimezoneDatabase.getTimezone(tzid)
if tz is not None:
return tz.getTimezoneDescriptor(dt)
else:
return ""
@staticmethod
def isStandardTimezone(tzid):
return TimezoneDatabase.getTimezoneDatabase()._isStandardTimezone(tzid)
def cacheTimezone(self, tzid):
"""
Load the specified timezone identifier's timezone data from a file and parse it
into the L{Calendar} used to store timezones used by this object.
@param tzid: the timezone identifier to load
@type tzid: L{str}
#.........这里部分代码省略.........