Back to index

python3.2  3.2.2
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
datetime.time Class Reference
Inheritance diagram for datetime.time:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __new__
def hour
def minute
def second
def microsecond
def tzinfo
def __eq__
def __ne__
def __le__
def __lt__
def __ge__
def __gt__
def __hash__
def __repr__
def isoformat
def strftime
def __format__
def utcoffset
def tzname
def dst
def replace
def __bool__
def __reduce__

Private Member Functions

def _cmp
def _tzstr
def _getstate
def __setstate

Private Attributes

 _hour
 _minute
 _second
 _microsecond
 _tzinfo

Static Private Attributes

 __str__ = isoformat

Detailed Description

Time with time zone.

Constructors:

__new__()

Operators:

__repr__, __str__
__cmp__, __hash__

Methods:

strftime()
isoformat()
utcoffset()
tzname()
dst()

Properties (readonly):
hour, minute, second, microsecond, tzinfo

Definition at line 993 of file datetime.py.


Member Function Documentation

def datetime.time.__bool__ (   self)

Definition at line 1264 of file datetime.py.

01264 
01265     def __bool__(self):
01266         if self.second or self.microsecond:
01267             return True
01268         offset = self.utcoffset() or timedelta(0)
01269         return timedelta(hours=self.hour, minutes=self.minute) != offset

Here is the call graph for this function:

def datetime.time.__eq__ (   self,
  other 
)

Definition at line 1070 of file datetime.py.

01070 
01071     def __eq__(self, other):
01072         if isinstance(other, time):
01073             return self._cmp(other) == 0
01074         else:
01075             return False

Here is the call graph for this function:

Here is the caller graph for this function:

def datetime.time.__format__ (   self,
  fmt 
)

Definition at line 1203 of file datetime.py.

01203 
01204     def __format__(self, fmt):
01205         if len(fmt) != 0:
01206             return self.strftime(fmt)
01207         return str(self)

Here is the call graph for this function:

def datetime.time.__ge__ (   self,
  other 
)

Definition at line 1094 of file datetime.py.

01094 
01095     def __ge__(self, other):
01096         if isinstance(other, time):
01097             return self._cmp(other) >= 0
01098         else:
01099             _cmperror(self, other)

Here is the call graph for this function:

def datetime.time.__gt__ (   self,
  other 
)

Definition at line 1100 of file datetime.py.

01100 
01101     def __gt__(self, other):
01102         if isinstance(other, time):
01103             return self._cmp(other) > 0
01104         else:
01105             _cmperror(self, other)

Here is the call graph for this function:

def datetime.time.__hash__ (   self)
Hash.

Definition at line 1131 of file datetime.py.

01131 
01132     def __hash__(self):
01133         """Hash."""
01134         tzoff = self.utcoffset()
01135         if not tzoff: # zero or None
01136             return hash(self._getstate()[0])
01137         h, m = divmod(timedelta(hours=self.hour, minutes=self.minute) - tzoff,
01138                       timedelta(hours=1))
01139         assert not m % timedelta(minutes=1), "whole minute"
01140         m //= timedelta(minutes=1)
01141         if 0 <= h < 24:
01142             return hash(time(h, m, self.second, self.microsecond))
01143         return hash((h, m, self.second, self.microsecond))

Here is the call graph for this function:

def datetime.time.__le__ (   self,
  other 
)

Definition at line 1082 of file datetime.py.

01082 
01083     def __le__(self, other):
01084         if isinstance(other, time):
01085             return self._cmp(other) <= 0
01086         else:
01087             _cmperror(self, other)

Here is the call graph for this function:

def datetime.time.__lt__ (   self,
  other 
)

Definition at line 1088 of file datetime.py.

01088 
01089     def __lt__(self, other):
01090         if isinstance(other, time):
01091             return self._cmp(other) < 0
01092         else:
01093             _cmperror(self, other)

Here is the call graph for this function:

def datetime.time.__ne__ (   self,
  other 
)

Definition at line 1076 of file datetime.py.

01076 
01077     def __ne__(self, other):
01078         if isinstance(other, time):
01079             return self._cmp(other) != 0
01080         else:
01081             return True

Here is the call graph for this function:

def datetime.time.__new__ (   cls,
  hour = 0,
  minute = 0,
  second = 0,
  microsecond = 0,
  tzinfo = None 
)
Constructor.

Arguments:

hour, minute (required)
second, microsecond (default to zero)
tzinfo (default to None)

Definition at line 1017 of file datetime.py.

01017 
01018     def __new__(cls, hour=0, minute=0, second=0, microsecond=0, tzinfo=None):
01019         """Constructor.
01020 
01021         Arguments:
01022 
01023         hour, minute (required)
01024         second, microsecond (default to zero)
01025         tzinfo (default to None)
01026         """
01027         self = object.__new__(cls)
01028         if isinstance(hour, bytes) and len(hour) == 6:
01029             # Pickle support
01030             self.__setstate(hour, minute or None)
01031             return self
01032         _check_tzinfo_arg(tzinfo)
01033         _check_time_fields(hour, minute, second, microsecond)
01034         self._hour = hour
01035         self._minute = minute
01036         self._second = second
01037         self._microsecond = microsecond
01038         self._tzinfo = tzinfo
01039         return self

Here is the call graph for this function:

def datetime.time.__reduce__ (   self)

Definition at line 1293 of file datetime.py.

01293 
01294     def __reduce__(self):
01295         return (time, self._getstate())

Here is the call graph for this function:

def datetime.time.__repr__ (   self)
Convert to formal string, for repr().

Definition at line 1162 of file datetime.py.

01162 
01163     def __repr__(self):
01164         """Convert to formal string, for repr()."""
01165         if self._microsecond != 0:
01166             s = ", %d, %d" % (self._second, self._microsecond)
01167         elif self._second != 0:
01168             s = ", %d" % self._second
01169         else:
01170             s = ""
01171         s= "%s(%d, %d%s)" % ('datetime.' + self.__class__.__name__,
01172                              self._hour, self._minute, s)
01173         if self._tzinfo is not None:
01174             assert s[-1:] == ")"
01175             s = s[:-1] + ", tzinfo=%r" % self._tzinfo + ")"
01176         return s

def datetime.time.__setstate (   self,
  string,
  tzinfo 
) [private]

Definition at line 1282 of file datetime.py.

01282 
01283     def __setstate(self, string, tzinfo):
01284         if len(string) != 6 or string[0] >= 24:
01285             raise TypeError("an integer is required")
01286         (self._hour, self._minute, self._second,
01287          us1, us2, us3) = string
01288         self._microsecond = (((us1 << 8) | us2) << 8) | us3
01289         if tzinfo is None or isinstance(tzinfo, _tzinfo_class):
01290             self._tzinfo = tzinfo
01291         else:
01292             raise TypeError("bad tzinfo state arg %r" % tzinfo)

Here is the caller graph for this function:

def datetime.time._cmp (   self,
  other 
) [private]

Definition at line 1106 of file datetime.py.

01106 
01107     def _cmp(self, other):
01108         assert isinstance(other, time)
01109         mytz = self._tzinfo
01110         ottz = other._tzinfo
01111         myoff = otoff = None
01112 
01113         if mytz is ottz:
01114             base_compare = True
01115         else:
01116             myoff = self.utcoffset()
01117             otoff = other.utcoffset()
01118             base_compare = myoff == otoff
01119 
01120         if base_compare:
01121             return _cmp((self._hour, self._minute, self._second,
01122                          self._microsecond),
01123                        (other._hour, other._minute, other._second,
01124                         other._microsecond))
01125         if myoff is None or otoff is None:
01126             raise TypeError("cannot compare naive and aware times")
01127         myhhmm = self._hour * 60 + self._minute - myoff//timedelta(minutes=1)
01128         othhmm = other._hour * 60 + other._minute - otoff//timedelta(minutes=1)
01129         return _cmp((myhhmm, self._second, self._microsecond),
01130                     (othhmm, other._second, other._microsecond))

Here is the call graph for this function:

Here is the caller graph for this function:

def datetime.time._getstate (   self) [private]

Definition at line 1272 of file datetime.py.

01272 
01273     def _getstate(self):
01274         us2, us3 = divmod(self._microsecond, 256)
01275         us1, us2 = divmod(us2, 256)
01276         basestate = bytes([self._hour, self._minute, self._second,
01277                            us1, us2, us3])
01278         if self._tzinfo is None:
01279             return (basestate,)
01280         else:
01281             return (basestate, self._tzinfo)

Here is the call graph for this function:

Here is the caller graph for this function:

def datetime.time._tzstr (   self,
  sep = ":" 
) [private]
Return formatted timezone offset (+xx:xx) or None.

Definition at line 1146 of file datetime.py.

01146 
01147     def _tzstr(self, sep=":"):
01148         """Return formatted timezone offset (+xx:xx) or None."""
01149         off = self.utcoffset()
01150         if off is not None:
01151             if off.days < 0:
01152                 sign = "-"
01153                 off = -off
01154             else:
01155                 sign = "+"
01156             hh, mm = divmod(off, timedelta(hours=1))
01157             assert not mm % timedelta(minutes=1), "whole minute"
01158             mm //= timedelta(minutes=1)
01159             assert 0 <= hh < 24
01160             off = "%s%02d%s%02d" % (sign, hh, sep, mm)
01161         return off

Here is the call graph for this function:

Here is the caller graph for this function:

def datetime.time.dst (   self)
Return 0 if DST is not in effect, or the DST offset (in minutes
eastward) if DST is in effect.

This is purely informational; the DST offset has already been added to
the UTC offset returned by utcoffset() if applicable, so there's no
need to consult dst() unless you're interested in displaying the DST
info.

Definition at line 1232 of file datetime.py.

01232 
01233     def dst(self):
01234         """Return 0 if DST is not in effect, or the DST offset (in minutes
01235         eastward) if DST is in effect.
01236 
01237         This is purely informational; the DST offset has already been added to
01238         the UTC offset returned by utcoffset() if applicable, so there's no
01239         need to consult dst() unless you're interested in displaying the DST
01240         info.
01241         """
01242         if self._tzinfo is None:
01243             return None
01244         offset = self._tzinfo.dst(None)
01245         _check_utc_offset("dst", offset)
01246         return offset

Here is the call graph for this function:

Here is the caller graph for this function:

def datetime.time.hour (   self)
hour (0-23)

Definition at line 1042 of file datetime.py.

01042 
01043     def hour(self):
01044         """hour (0-23)"""
01045         return self._hour

Here is the caller graph for this function:

def datetime.time.isoformat (   self)
Return the time formatted according to ISO.

This is 'HH:MM:SS.mmmmmm+zz:zz', or 'HH:MM:SS+zz:zz' if
self.microsecond == 0.

Definition at line 1177 of file datetime.py.

01177 
01178     def isoformat(self):
01179         """Return the time formatted according to ISO.
01180 
01181         This is 'HH:MM:SS.mmmmmm+zz:zz', or 'HH:MM:SS+zz:zz' if
01182         self.microsecond == 0.
01183         """
01184         s = _format_time(self._hour, self._minute, self._second,
01185                          self._microsecond)
01186         tz = self._tzstr()
01187         if tz:
01188             s += tz
01189         return s

Here is the call graph for this function:

def datetime.time.microsecond (   self)
microsecond (0-999999)

Definition at line 1057 of file datetime.py.

01057 
01058     def microsecond(self):
01059         """microsecond (0-999999)"""
01060         return self._microsecond

Here is the caller graph for this function:

def datetime.time.minute (   self)
minute (0-59)

Definition at line 1047 of file datetime.py.

01047 
01048     def minute(self):
01049         """minute (0-59)"""
01050         return self._minute

Here is the caller graph for this function:

def datetime.time.replace (   self,
  hour = None,
  minute = None,
  second = None,
  microsecond = None,
  tzinfo = True 
)
Return a new time with new values for the specified fields.

Definition at line 1248 of file datetime.py.

01248 
01249                 tzinfo=True):
01250         """Return a new time with new values for the specified fields."""
01251         if hour is None:
01252             hour = self.hour
01253         if minute is None:
01254             minute = self.minute
01255         if second is None:
01256             second = self.second
01257         if microsecond is None:
01258             microsecond = self.microsecond
01259         if tzinfo is True:
01260             tzinfo = self.tzinfo
01261         _check_time_fields(hour, minute, second, microsecond)
01262         _check_tzinfo_arg(tzinfo)
01263         return time(hour, minute, second, microsecond, tzinfo)

Here is the call graph for this function:

Here is the caller graph for this function:

def datetime.time.second (   self)
second (0-59)

Definition at line 1052 of file datetime.py.

01052 
01053     def second(self):
01054         """second (0-59)"""
01055         return self._second

Here is the caller graph for this function:

def datetime.time.strftime (   self,
  fmt 
)
Format using strftime().  The date part of the timestamp passed
to underlying strftime should not be used.

Definition at line 1192 of file datetime.py.

01192 
01193     def strftime(self, fmt):
01194         """Format using strftime().  The date part of the timestamp passed
01195         to underlying strftime should not be used.
01196         """
01197         # The year must be >= 1000 else Python's strftime implementation
01198         # can raise a bogus exception.
01199         timetuple = (1900, 1, 1,
01200                      self._hour, self._minute, self._second,
01201                      0, 1, -1)
01202         return _wrap_strftime(self, fmt, timetuple)

Here is the call graph for this function:

Here is the caller graph for this function:

def datetime.time.tzinfo (   self)
timezone info object

Definition at line 1062 of file datetime.py.

01062 
01063     def tzinfo(self):
01064         """timezone info object"""
01065         return self._tzinfo

Here is the caller graph for this function:

def datetime.time.tzname (   self)
Return the timezone name.

Note that the name is 100% informational -- there's no requirement that
it mean anything in particular. For example, "GMT", "UTC", "-500",
"-5:00", "EDT", "US/Eastern", "America/New York" are all valid replies.

Definition at line 1219 of file datetime.py.

01219 
01220     def tzname(self):
01221         """Return the timezone name.
01222 
01223         Note that the name is 100% informational -- there's no requirement that
01224         it mean anything in particular. For example, "GMT", "UTC", "-500",
01225         "-5:00", "EDT", "US/Eastern", "America/New York" are all valid replies.
01226         """
01227         if self._tzinfo is None:
01228             return None
01229         name = self._tzinfo.tzname(None)
01230         _check_tzname(name)
01231         return name

Here is the call graph for this function:

def datetime.time.utcoffset (   self)
Return the timezone offset in minutes east of UTC (negative west of
UTC).

Definition at line 1210 of file datetime.py.

01210 
01211     def utcoffset(self):
01212         """Return the timezone offset in minutes east of UTC (negative west of
01213         UTC)."""
01214         if self._tzinfo is None:
01215             return None
01216         offset = self._tzinfo.utcoffset(None)
01217         _check_utc_offset("utcoffset", offset)
01218         return offset

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

datetime.time.__str__ = isoformat [static, private]

Definition at line 1190 of file datetime.py.

Definition at line 1033 of file datetime.py.

Definition at line 1036 of file datetime.py.

Definition at line 1034 of file datetime.py.

Definition at line 1035 of file datetime.py.

Definition at line 1037 of file datetime.py.


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