tzinfo.{utcoffset,dst} can return timedelta (or integer or None).

{timetz,datetimetz}.{uctcoffset,dst} do return timedelta (or None).
This commit is contained in:
Tim Peters 2002-12-24 16:25:29 +00:00
parent 78ce6b10ed
commit 1cff9fc97c
1 changed files with 21 additions and 15 deletions

View File

@ -773,7 +773,9 @@ argument of \code{None} or of type \class{timetz} or
\method{utcoffset()} should return their sum. If the UTC offset \method{utcoffset()} should return their sum. If the UTC offset
isn't known, return \code{None}. Else the value returned must be isn't known, return \code{None}. Else the value returned must be
an integer, in the range -1439 to 1439 inclusive (1440 = 24*60; an integer, in the range -1439 to 1439 inclusive (1440 = 24*60;
the magnitude of the offset must be less than one day). the magnitude of the offset must be less than one day), or a
\class{timedelta} object representing a whole number of minutes
in the same range.
- tzname(dt) - tzname(dt)
Return the timezone name corresponding to the \class{datetime} represented Return the timezone name corresponding to the \class{datetime} represented
@ -789,13 +791,14 @@ argument of \code{None} or of type \class{timetz} or
- dst(dt) - dst(dt)
Return the DST offset, in minutes east of UTC, or \code{None} if Return the DST offset, in minutes east of UTC, or \code{None} if
DST information isn't known. Return 0 if DST is not in effect. DST information isn't known. Return 0 if DST is not in effect.
If DST is in effect, return an int (or long), in the range -1439 If DST is in effect, return the offset as an integer or
to 1439 inclusive. Note that DST offset, if applicable, has \class{timedelta} object (see \method{utcoffset()} for details).
Note that DST offset, if applicable, has
already been added to the UTC offset returned by already been added to the UTC offset returned by
\method{utcoffset()}, so there's no need to consult \method{dst()} \method{utcoffset()}, so there's no need to consult \method{dst()}
unless you're interested in displaying DST info separately. For unless you're interested in displaying DST info separately. For
example, \method{datetimetz.timetuple()} calls its \class{tzinfo} example, \method{datetimetz.timetuple()} calls its \member{tzinfo}
object's \method{dst()} method to determine how the member's \method{dst()} method to determine how the
\member{tm_isdst} flag should be set. \member{tm_isdst} flag should be set.
Example \class{tzinfo} classes: Example \class{tzinfo} classes:
@ -899,7 +902,8 @@ Instance methods:
- utcoffset() - utcoffset()
If \member{tzinfo} is \code{None}, returns \code{None}, else If \member{tzinfo} is \code{None}, returns \code{None}, else
\code{tzinfo.utcoffset(self)}. \code{tzinfo.utcoffset(self)} converted to a \class{timedelta}
object.
- tzname(): - tzname():
If \member{tzinfo} is \code{None}, returns \code{None}, else If \member{tzinfo} is \code{None}, returns \code{None}, else
@ -907,7 +911,7 @@ Instance methods:
- dst() - dst()
If \member{tzinfo} is \code{None}, returns \code{None}, else If \member{tzinfo} is \code{None}, returns \code{None}, else
\code{tzinfo.dst(self)}. \code{tzinfo.dst(self)} converted to a \class{timedelta} object.
@ -1024,8 +1028,8 @@ Supported operations:
\item \item
If both are aware \class{datetimetz} objects, a-b acts as if a and b were If both are aware \class{datetimetz} objects, a-b acts as if a and b were
first converted to UTC datetimes (by subtracting a.utcoffset() first converted to UTC datetimes (by subtracting \code{a.utcoffset()}
minutes from a, and b.utcoffset() minutes from b), and then doing minutes from a, and \code{b.utcoffset()} minutes from b), and then doing
\class{datetime} subtraction, except that the implementation never \class{datetime} subtraction, except that the implementation never
overflows. overflows.
@ -1077,7 +1081,8 @@ Instance methods:
- utcoffset() - utcoffset()
If \member{tzinfo} is \code{None}, returns \code{None}, else If \member{tzinfo} is \code{None}, returns \code{None}, else
\code{tzinfo.utcoffset(self)}. \code{tzinfo.utcoffset(self)} converted to a \class{timedelta}
object.
- tzname() - tzname()
If \member{tzinfo} is \code{None}, returns \code{None}, else If \member{tzinfo} is \code{None}, returns \code{None}, else
@ -1085,7 +1090,8 @@ Instance methods:
- dst() - dst()
If \member{tzinfo} is \code{None}, returns \code{None}, else If \member{tzinfo} is \code{None}, returns \code{None}, else
\code{tzinfo.dst(self)}. \code{tzinfo.dst(self)} converted to a \class{timedelta}
object.
- timetuple() - timetuple()
Like \function{datetime.timetuple()}, but sets the Like \function{datetime.timetuple()}, but sets the
@ -1172,8 +1178,8 @@ For an aware object:
the form +HHMM or -HHMM, where HH is a 2-digit string giving the the form +HHMM or -HHMM, where HH is a 2-digit string giving the
number of UTC offset hours, and MM is a 2-digit string giving the number of UTC offset hours, and MM is a 2-digit string giving the
number of UTC offset minutes. For example, if number of UTC offset minutes. For example, if
\method{utcoffset()} returns -180, \code{\%z} is replaced with the \method{utcoffset()} returns \code{timedelta(hours=-3, minutes=-30}},
string \code{'-0300'}. \code{\%z} is replaced with the string \code{'-0330'}.
\item[\code{\%Z}] \item[\code{\%Z}]
If \method{tzname()} returns \code{None}, \code{\%Z} is replaced If \method{tzname()} returns \code{None}, \code{\%Z} is replaced
@ -1234,7 +1240,7 @@ Accessor macros:
All objects are immutable, so accessors are read-only. All macros All objects are immutable, so accessors are read-only. All macros
return ints: return ints:
For date, datetime, and \class{datetimetz} instances: For \class{date}, \class{datetime}, and \class{datetimetz} instances:
PyDateTime_GET_YEAR(o) PyDateTime_GET_YEAR(o)
PyDateTime_GET_MONTH(o) PyDateTime_GET_MONTH(o)
PyDateTime_GET_DAY(o) PyDateTime_GET_DAY(o)
@ -1245,7 +1251,7 @@ return ints:
PyDateTime_DATE_GET_SECOND(o) PyDateTime_DATE_GET_SECOND(o)
PyDateTime_DATE_GET_MICROSECOND(o) PyDateTime_DATE_GET_MICROSECOND(o)
For time and \class{timetz} instances: For \class{time} and \class{timetz} instances:
PyDateTime_TIME_GET_HOUR(o) PyDateTime_TIME_GET_HOUR(o)
PyDateTime_TIME_GET_MINUTE(o) PyDateTime_TIME_GET_MINUTE(o)
PyDateTime_TIME_GET_SECOND(o) PyDateTime_TIME_GET_SECOND(o)