pytz.tzinfo (version 540)
index
/astro-wise/AWEHOME/x86_64/AWBASE/common/lib/python2.5/site-packages/pytz/tzinfo.py

$Id: tzinfo.py 540 2004-09-24 15:24:50Z jdh2358 $

 
Classes
       
datetime.tzinfo(__builtin__.object)
BaseTzInfo
DstTzInfo
StaticTzInfo
exceptions.Exception(exceptions.BaseException)
AmbiguousTimeError

 
class AmbiguousTimeError(exceptions.Exception)
    Exception raised when attempting to create an ambiguous wallclock time.
 
At the end of a DST transition period, a particular wallclock time will
occur twice (once before the clocks are set back, once after). Both
possibilities may be correct, unless further information is supplied.
 
See DstTzInfo.normalize() for more info
 
 
Method resolution order:
AmbiguousTimeError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x71a8a0>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
class BaseTzInfo(datetime.tzinfo)
    
Method resolution order:
BaseTzInfo
datetime.tzinfo
__builtin__.object

Methods defined here:
__str__(self)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from datetime.tzinfo:
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__reduce__(...)
-> (cls, state)
dst(...)
datetime -> DST offset in minutes east of UTC.
fromutc(...)
datetime in UTC -> datetime in local time.
tzname(...)
datetime -> string name of time zone.
utcoffset(...)
datetime -> minutes east of UTC (negative for west of UTC).

Data and other attributes inherited from datetime.tzinfo:
__new__ = <built-in method __new__ of type object at 0x2aaab01d8ea0>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
class DstTzInfo(BaseTzInfo)
    A timezone that has a variable offset from UTC
 
The offset might change if daylight savings time comes into effect,
or at a point in history when the region decides to change their 
timezone definition.
 
 
Method resolution order:
DstTzInfo
BaseTzInfo
datetime.tzinfo
__builtin__.object

Methods defined here:
__init__(self, _inf=None, _tzinfos=None)
__repr__(self)
dst(self, dt)
See datetime.tzinfo.dst
fromutc(self, dt)
See datetime.tzinfo.fromutc
localize(self, dt, is_dst=False)
Convert naive time to local time.
 
This method should be used to construct localtimes, rather
than passing a tzinfo argument to a datetime constructor.
 
is_dst is used to determine the correct timezone in the ambigous
period at the end of daylight savings time.
 
>>> from pytz import timezone
>>> fmt = '%Y-%m-%d %H:%M:%S %Z (%z)'
>>> amdam = timezone('Europe/Amsterdam')
>>> dt  = datetime(2004, 10, 31, 2, 0, 0)
>>> loc_dt1 = amdam.localize(dt, is_dst=True)
>>> loc_dt2 = amdam.localize(dt, is_dst=False)
>>> loc_dt1.strftime(fmt)
'2004-10-31 02:00:00 CEST (+0200)'
>>> loc_dt2.strftime(fmt)
'2004-10-31 02:00:00 CET (+0100)'
>>> str(loc_dt2 - loc_dt1)
'1:00:00'
 
Use is_dst=None to raise an AmbiguousTimeError for ambiguous
times at the end of daylight savings
 
>>> try:
...     loc_dt1 = amdam.localize(dt, is_dst=None)
... except AmbiguousTimeError:
...     print 'Oops'
Oops
 
>>> loc_dt1 = amdam.localize(dt, is_dst=None)
Traceback (most recent call last):
    [...]
AmbiguousTimeError: 2004-10-31 02:00:00
 
is_dst defaults to False
 
>>> amdam.localize(dt) == amdam.localize(dt, False)
True
normalize(self, dt)
Correct the timezone information on the given datetime
 
If date arithmetic crosses DST boundaries, the tzinfo
is not magically adjusted. This method normalizes the
tzinfo to the correct one.
 
To test, first we need to do some setup
 
>>> from pytz import timezone
>>> utc = timezone('UTC')
>>> eastern = timezone('US/Eastern')
>>> fmt = '%Y-%m-%d %H:%M:%S %Z (%z)'
 
We next create a datetime right on an end-of-DST transition point,
the instant when the wallclocks are wound back one hour.
 
>>> utc_dt = datetime(2002, 10, 27, 6, 0, 0, tzinfo=utc)
>>> loc_dt = utc_dt.astimezone(eastern)
>>> loc_dt.strftime(fmt)
'2002-10-27 01:00:00 EST (-0500)'
 
Now, if we subtract a few minutes from it, note that the timezone
information has not changed.
 
>>> before = loc_dt - timedelta(minutes=10)
>>> before.strftime(fmt)
'2002-10-27 00:50:00 EST (-0500)'
 
But we can fix that by calling the normalize method
 
>>> before = eastern.normalize(before)
>>> before.strftime(fmt)
'2002-10-27 01:50:00 EDT (-0400)'
tzname(self, dt)
See datetime.tzinfo.tzname
utcoffset(self, dt)
See datetime.tzinfo.utcoffset

Methods inherited from BaseTzInfo:
__str__(self)

Data descriptors inherited from BaseTzInfo:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from datetime.tzinfo:
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__reduce__(...)
-> (cls, state)

Data and other attributes inherited from datetime.tzinfo:
__new__ = <built-in method __new__ of type object at 0x2aaab01d8ea0>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
class StaticTzInfo(BaseTzInfo)
    A timezone that has a constant offset from UTC
 
These timezones are rare, as most regions have changed their
offset from UTC at some point in their history
 
 
Method resolution order:
StaticTzInfo
BaseTzInfo
datetime.tzinfo
__builtin__.object

Methods defined here:
__repr__(self)
dst(self, dt)
See datetime.tzinfo.dst
fromutc(self, dt)
See datetime.tzinfo.fromutc
localize(self, dt, is_dst=False)
Convert naive time to local time
normalize(self, dt, is_dst=False)
Correct the timezone information on the given datetime
tzname(self, dt)
See datetime.tzinfo.tzname
utcoffset(self, dt)
See datetime.tzinfo.utcoffset

Methods inherited from BaseTzInfo:
__str__(self)

Data descriptors inherited from BaseTzInfo:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from datetime.tzinfo:
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__reduce__(...)
-> (cls, state)

Data and other attributes inherited from datetime.tzinfo:
__new__ = <built-in method __new__ of type object at 0x2aaab01d8ea0>
T.__new__(S, ...) -> a new object with type S, a subtype of T

 
Functions
       
bisect_right(...)
bisect_right(a, x[, lo[, hi]]) -> index
 
Return the index where to insert item x in list a, assuming a is sorted.
 
The return value i is such that all e in a[:i] have e <= x, and all e in
a[i:] have e > x.  So if x already appears in the list, i points just
beyond the rightmost x already there
 
Optional args lo (default 0) and hi (default len(a)) bound the
slice of a to be searched.
memorized_datetime(*args)
Create only one instance of each distinct datetime
memorized_timedelta(seconds)
Create only one instance of each distinct timedelta
memorized_ttinfo(*args)
Create only one instance of each distinct tuple

 
Data
        __rcs_id__ = '$Id: tzinfo.py 540 2004-09-24 15:24:50Z jdh2358 $'
__version__ = '540'