00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 """Timezone related utilities for BSON."""
00016
00017 from datetime import (timedelta,
00018 tzinfo)
00019
00020 ZERO = timedelta(0)
00021
00022
00023 class FixedOffset(tzinfo):
00024 """Fixed offset timezone, in minutes east from UTC.
00025
00026 Implementation from the Python `standard library documentation
00027 <http://docs.python.org/library/datetime.html#tzinfo-objects>`_.
00028 """
00029
00030 def __init__(self, offset, name):
00031 self.__offset = timedelta(minutes=offset)
00032 self.__name = name
00033
00034 def utcoffset(self, dt):
00035 return self.__offset
00036
00037 def tzname(self, dt):
00038 return self.__name
00039
00040 def dst(self, dt):
00041 return ZERO
00042
00043
00044 utc = FixedOffset(0, "UTC")
00045 """Fixed offset timezone representing UTC."""