Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
tzinfo-examples.USTimeZone Class Reference
Inheritance diagram for tzinfo-examples.USTimeZone:
Inheritance graph
[legend]
Collaboration diagram for tzinfo-examples.USTimeZone:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __repr__
def tzname
def utcoffset
def dst
def fromutc
def __reduce__

Public Attributes

 stdoffset
 reprname
 stdname
 dstname

Detailed Description

Definition at line 116 of file tzinfo-examples.py.


Constructor & Destructor Documentation

def tzinfo-examples.USTimeZone.__init__ (   self,
  hours,
  reprname,
  stdname,
  dstname 
)

Definition at line 118 of file tzinfo-examples.py.

00118 
00119     def __init__(self, hours, reprname, stdname, dstname):
00120         self.stdoffset = timedelta(hours=hours)
00121         self.reprname = reprname
00122         self.stdname = stdname
00123         self.dstname = dstname

Here is the caller graph for this function:


Member Function Documentation

def datetime.tzinfo.__reduce__ (   self) [inherited]

Definition at line 975 of file datetime.py.

00975 
00976     def __reduce__(self):
00977         getinitargs = getattr(self, "__getinitargs__", None)
00978         if getinitargs:
00979             args = getinitargs()
00980         else:
00981             args = ()
00982         getstate = getattr(self, "__getstate__", None)
00983         if getstate:
00984             state = getstate()
00985         else:
00986             state = getattr(self, "__dict__", None) or None
00987         if state is None:
00988             return (self.__class__, args)
00989         else:
00990             return (self.__class__, args, state)

Here is the call graph for this function:

def tzinfo-examples.USTimeZone.__repr__ (   self)

Definition at line 124 of file tzinfo-examples.py.

00124 
00125     def __repr__(self):
00126         return self.reprname

def tzinfo-examples.USTimeZone.dst (   self,
  dt 
)
datetime -> DST offset in minutes east of UTC.

Return 0 if DST not in effect.  utcoffset() must include the DST
offset.

Reimplemented from datetime.tzinfo.

Definition at line 136 of file tzinfo-examples.py.

00136 
00137     def dst(self, dt):
00138         if dt is None or dt.tzinfo is None:
00139             # An exception may be sensible here, in one or both cases.
00140             # It depends on how you want to treat them.  The default
00141             # fromutc() implementation (called by the default astimezone()
00142             # implementation) passes a datetime with dt.tzinfo is self.
00143             return ZERO
00144         assert dt.tzinfo is self
00145 
00146         # Find start and end times for US DST. For years before 1967, return
00147         # ZERO for no DST.
00148         if 2006 < dt.year:
00149             dststart, dstend = DSTSTART_2007, DSTEND_2007
00150         elif 1986 < dt.year < 2007:
00151             dststart, dstend = DSTSTART_1987_2006, DSTEND_1987_2006
00152         elif 1966 < dt.year < 1987:
00153             dststart, dstend = DSTSTART_1967_1986, DSTEND_1967_1986
00154         else:
00155             return ZERO
00156 
00157         start = first_sunday_on_or_after(dststart.replace(year=dt.year))
00158         end = first_sunday_on_or_after(dstend.replace(year=dt.year))
00159 
00160         # Can't compare naive to aware objects, so strip the timezone from
00161         # dt first.
00162         if start <= dt.replace(tzinfo=None) < end:
00163             return HOUR
00164         else:
00165             return ZERO

Here is the call graph for this function:

Here is the caller graph for this function:

def datetime.tzinfo.fromutc (   self,
  dt 
) [inherited]

Reimplemented in datetime.timezone.

Definition at line 946 of file datetime.py.

00946 
00947     def fromutc(self, dt):
00948         "datetime in UTC -> datetime in local time."
00949 
00950         if not isinstance(dt, datetime):
00951             raise TypeError("fromutc() requires a datetime argument")
00952         if dt.tzinfo is not self:
00953             raise ValueError("dt.tzinfo is not self")
00954 
00955         dtoff = dt.utcoffset()
00956         if dtoff is None:
00957             raise ValueError("fromutc() requires a non-None utcoffset() "
00958                              "result")
00959 
00960         # See the long comment block at the end of this file for an
00961         # explanation of this algorithm.
00962         dtdst = dt.dst()
00963         if dtdst is None:
00964             raise ValueError("fromutc() requires a non-None dst() result")
00965         delta = dtoff - dtdst
00966         if delta:
00967             dt += delta
00968             dtdst = dt.dst()
00969             if dtdst is None:
00970                 raise ValueError("fromutc(): dt.dst gave inconsistent "
00971                                  "results; cannot convert")
00972         return dt + dtdst

def tzinfo-examples.USTimeZone.tzname (   self,
  dt 
)

Reimplemented from datetime.tzinfo.

Definition at line 127 of file tzinfo-examples.py.

00127 
00128     def tzname(self, dt):
00129         if self.dst(dt):
00130             return self.dstname
00131         else:
00132             return self.stdname

Here is the call graph for this function:

Here is the caller graph for this function:

def tzinfo-examples.USTimeZone.utcoffset (   self,
  dt 
)

Reimplemented from datetime.tzinfo.

Definition at line 133 of file tzinfo-examples.py.

00133 
00134     def utcoffset(self, dt):
00135         return self.stdoffset + self.dst(dt)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

tzinfo-examples.USTimeZone.dstname

Definition at line 122 of file tzinfo-examples.py.

tzinfo-examples.USTimeZone.reprname

Definition at line 120 of file tzinfo-examples.py.

tzinfo-examples.USTimeZone.stdname

Definition at line 121 of file tzinfo-examples.py.

tzinfo-examples.USTimeZone.stdoffset

Definition at line 119 of file tzinfo-examples.py.


The documentation for this class was generated from the following file: