Commit 436eadd4 authored by Fred Drake's avatar Fred Drake

General style conformance. Markup some unmarked constructs.

parent 2cb54025
......@@ -146,10 +146,10 @@ between two dates or times.
internally. Arguments are converted to those units:
\begin{verbatim}
A millisecond is converted to 1000 microseconds.
A minute is converted to 60 seconds.
An hour is converted to 3600 seconds.
A week is converted to 7 days.
A millisecond is converted to 1000 microseconds.
A minute is converted to 60 seconds.
An hour is converted to 3600 seconds.
A week is converted to 7 days.
\end{verbatim}
and days, seconds and microseconds are then normalized so that the
......@@ -219,7 +219,8 @@ Supported operations:
{(1)}
\lineiii{\var{t1} = \var{t2} * \var{i} or \var{t1} = \var{i} * \var{t2}}
{Delta multiplied by an integer or long.
Afterwards \var{t1} // i == \var{t2} is true, provided \code{i != 0}.
Afterwards \var{t1} // i == \var{t2} is true,
provided \code{i != 0}.
In general, \var{t1} * i == \var{t1} * (i-1) + \var{t1} is true.}
{(1)}
\lineiii{\var{t1} = \var{t2} // \var{i}}
......@@ -233,25 +234,22 @@ Supported operations:
-\var{t1.microseconds}),and to \var{t1}* -1.}
{(1)(3)}
\lineiii{abs(\var{t})}
{equivalent to +\var{t} when \code{t.days >= 0}, and to -\var{t} when
\code{t.days < 0}.}
{equivalent to +\var{t} when \code{t.days >= 0}, and to
-\var{t} when \code{t.days < 0}.}
{(1)}
\end{tableiii}
\noindent
Notes:
\begin{description}
\item[(1)]
This is exact, but may overflow.
This is exact, but may overflow.
\item[(2)]
Division by 0 raises \exception{ZeroDivisionError}.
Division by 0 raises \exception{ZeroDivisionError}.
\item[(3)]
-\var{timedelta.max} is not representable as a \class{timedelta} object.
-\var{timedelta.max} is not representable as a \class{timedelta} object.
\end{description}
In addition to the operations listed above \class{timedelta} objects
......@@ -280,18 +278,17 @@ computations. See the book for algorithms for converting between
proleptic Gregorian ordinals and many other calendar systems.
\begin{funcdesc}{date}{year, month, day}
All arguments are required. Arguments may be ints or longs, in the
following ranges:
\begin{itemize}
\begin{itemize}
\item \code{MINYEAR <= \var{year} <= MAXYEAR}
\item \code{1 <= \var{month} <= 12}
\item \code{1 <= \var{day} <= number of days in the given month and year}
\end{itemize}
\end{itemize}
If an argument outside those ranges is given, \exception{ValueError}
is raised.
If an argument outside those ranges is given, \exception{ValueError}
is raised.
\end{funcdesc}
Other constructors, all class methods:
......@@ -312,9 +309,10 @@ Other constructors, all class methods:
\begin{methoddesc}{fromordinal}{ordinal}
Return the date corresponding to the proleptic Gregorian ordinal,
where January 1 of year 1 has ordinal 1. \exception{ValueError}
is raised unless \code{1 <= \var{ordinal} <= date.max.toordinal()}. For any
date \var{d}, \code{date.fromordinal(\var{d}.toordinal()) == \var{d}}.
where January 1 of year 1 has ordinal 1. \exception{ValueError} is
raised unless \code{1 <= \var{ordinal} <= date.max.toordinal()}.
For any date \var{d}, \code{date.fromordinal(\var{d}.toordinal()) ==
\var{d}}.
\end{methoddesc}
Class attributes:
......@@ -335,16 +333,16 @@ Class attributes:
Instance attributes (read-only):
\begin{memberdesc}{year}
Between \constant{MINYEAR} and \constant{MAXYEAR} inclusive
Between \constant{MINYEAR} and \constant{MAXYEAR} inclusive
\end{memberdesc}
\begin{memberdesc}{month}
Between 1 and 12 inclusive.
Between 1 and 12 inclusive.
\end{memberdesc}
\begin{memberdesc}{day}
Between 1 and the number of days in the given month
of the given year.
Between 1 and the number of days in the given month of the given
year.
\end{memberdesc}
Supported operations:
......@@ -409,23 +407,27 @@ Instance methods:
\# day of year
-1)}
\end{methoddesc}
\begin{methoddesc}{toordinal}{}
Return the proleptic Gregorian ordinal of the date, where January 1
of year 1 has ordinal 1. For any \class{date} object \var{d},
\code{date.fromordinal(\var{d}.toordinal()) == \var{d}}.
\end{methoddesc}
\begin{methoddesc}{weekday}{}
Return the day of the week as an integer, where Monday is 0 and
Sunday is 6. For example, date(2002, 12, 4).weekday() == 2, a
Wednesday.
See also \method{isoweekday()}.
\end{methoddesc}
\begin{methoddesc}{isoweekday}{}
Return the day of the week as an integer, where Monday is 1 and
Sunday is 7. For example, date(2002, 12, 4).isoweekday() == 3, a
Wednesday.
See also \method{weekday()}, \method{isocalendar()}.
\end{methoddesc}
\begin{methoddesc}{isocalendar}{}
Return a 3-tuple, (ISO year, ISO week number, ISO weekday).
......@@ -446,15 +448,18 @@ Instance methods:
date(2003, 12, 29).isocalendar() == (2004, 1, 1)
date(2004, 1, 4).isocalendar() == (2004, 1, 7)
\end{methoddesc}
\begin{methoddesc}{isoformat}{}
Return a string representing the date in ISO 8601 format,
'YYYY-MM-DD'. For example,
date(2002, 12, 4).isoformat() == '2002-12-04'.
\end{methoddesc}
\begin{methoddesc}{__str__}{}
For a date \var{d}, \code{str(\var{d})} is equivalent to
\code{\var{d}.isoformat()}.
\end{methoddesc}
\begin{methoddesc}{ctime}{}
Return a string representing the date, for example
date(2002, 12, 4).ctime() == 'Wed Dec 4 00:00:00 2002'.
......@@ -464,6 +469,7 @@ Instance methods:
(which \function{time.ctime()} invokes, but which
\method{date.ctime()} does not invoke) conforms to the C standard.
\end{methoddesc}
\begin{methoddesc}{strftime}{format}
Return a string representing the date, controlled by an explicit
format string. Format codes referring to hours, minutes or seconds
......@@ -483,10 +489,10 @@ day.
\begin{funcdesc}{datetime}{year, month, day,
hour=0, minute=0, second=0, microsecond=0}
The year, month and day arguments are required. Arguments may be ints
or longs, in the following ranges:
The year, month and day arguments are required. Arguments may be
ints or longs, in the following ranges:
\begin{itemize}
\begin{itemize}
\item \code{\member{MINYEAR} <= \var{year} <= \member{MAXYEAR}}
\item \code{1 <= \var{month} <= 12}
\item \code{1 <= \var{day} <= number of days in the given month and year}
......@@ -494,10 +500,10 @@ or longs, in the following ranges:
\item \code{0 <= \var{minute} < 60}
\item \code{0 <= \var{second} < 60}
\item \code{0 <= \var{microsecond} < 1000000}
\end{itemize}
\end{itemize}
If an argument outside those ranges is given,
\exception{ValueError} is raised.
If an argument outside those ranges is given, \exception{ValueError}
is raised.
\end{funcdesc}
Other constructors, all class methods:
......@@ -582,31 +588,32 @@ Class attributes:
Instance attributes (read-only):
\begin{memberdesc}{year}
Between \constant{MINYEAR} and \constant{MAXYEAR} inclusive
Between \constant{MINYEAR} and \constant{MAXYEAR} inclusive
\end{memberdesc}
\begin{memberdesc}{month}
Between 1 and 12 inclusive
Between 1 and 12 inclusive
\end{memberdesc}
\begin{memberdesc}{day}
Between 1 and the number of days in the given month of the given year.
Between 1 and the number of days in the given month of the given
year.
\end{memberdesc}
\begin{memberdesc}{hour}
In \code{range(24)}.
In \code{range(24)}.
\end{memberdesc}
\begin{memberdesc}{minute}
In \code{range(60)}.
In \code{range(60)}.
\end{memberdesc}
\begin{memberdesc}{second}
In \code{range(60)}.
In \code{range(60)}.
\end{memberdesc}
\begin{memberdesc}{microsecond}
In \code{range(1000000)}.
In \code{range(1000000)}.
\end{memberdesc}
Supported operations:
......@@ -659,7 +666,8 @@ Instance methods:
Return time object with same hour, minute, second and microsecond.
\end{methoddesc}
\begin{methoddesc}{replace}{year=, month=, day=, hour=, minute=, second=, microsecond=}
\begin{methoddesc}{replace}{year=, month=, day=, hour=, minute=,
second=, microsecond=}
Return a datetime with the same value, except for those fields given
new values by whichever keyword arguments are specified.
\end{methoddesc}
......@@ -744,8 +752,7 @@ Instance methods:
A \class{time} object represents an idealized time of day, independent
of day and timezone.
\begin{funcdesc}{hour=0, minute=0, second=0, microsecond=0}
\begin{funcdesc}{time}{hour=0, minute=0, second=0, microsecond=0}
All arguments are optional. They may be ints or longs, in the
following ranges:
......@@ -779,16 +786,19 @@ Class attributes:
Instance attributes (read-only):
\begin{memberdesc}{hour}
In \code{range(24)}.
In \code{range(24)}.
\end{memberdesc}
\begin{memberdesc}{minute}
In \code{range(60)}.
In \code{range(60)}.
\end{memberdesc}
\begin{memberdesc}{second}
In \code{range(60)}.
In \code{range(60)}.
\end{memberdesc}
\begin{memberdesc}{microsecond}
In \code{range(1000000)}.
In \code{range(1000000)}.
\end{memberdesc}
Supported operations:
......@@ -872,6 +882,7 @@ implement all of them.
\class{timedelta} object representing a whole number of minutes
in the same range. Most implementations of \method{utcoffset()}
will probably look like:
\begin{verbatim}
return CONSTANT # fixed-offset class
return CONSTANT + self.dst(dt) # daylight-aware class
......@@ -880,19 +891,20 @@ implement all of them.
\begin{methoddesc}{tzname}{self, dt}
Return the timezone name corresponding to the \class{datetime} represented
by dt, as a string. Nothing about string names is defined by the
by \var{dt}, as a string. Nothing about string names is defined by the
\module{datetime} module, and 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. Return
\code{None} if a string name isn't known. Note that this is a method
rather than a fixed string primarily because some \class{tzinfo} objects
will wish to return different names depending on the specific value
of dt passed, especially if the \class{tzinfo} class is accounting for DST.
of \var{dt} passed, especially if the \class{tzinfo} class is
accounting for DST.
\end{methoddesc}
\begin{methoddesc}{dst}{self, dt}
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 \code{0} if DST is not in effect.
If DST is in effect, return the offset as an integer or
\class{timedelta} object (see \method{utcoffset()} for details).
Note that DST offset, if applicable, has
......@@ -937,7 +949,6 @@ particular day, and subject to adjustment via a \class{tzinfo} object.
Constructor:
\begin{funcdesc}{time}{hour=0, minute=0, second=0, microsecond=0, tzinfo=None}
All arguments are optional. \var{tzinfo} may be \code{None}, or
an instance of a \class{tzinfo} subclass. The remaining arguments
may be ints or longs, in the following ranges:
......@@ -971,13 +982,26 @@ Class attributes:
Instance attributes (read-only):
.hour in range(24)
.minute in range(60)
.second in range(60)
.microsecond in range(1000000)
.tzinfo the object passed as the tzinfo argument to the
\class{timetz} constructor, or \code{None} if none
was passed.
\begin{memberdesc}{hour}
In \code{range(24)}.
\end{memberdesc}
\begin{memberdesc}{minute}
In \code{range(60)}.
\end{memberdesc}
\begin{memberdesc}{second}
In \code{range(60)}.
\end{memberdesc}
\begin{memberdesc}{microsecond}
In \code{range(1000000)}.
\end{memberdesc}
\begin{memberdesc}{tzinfo}
The object passed as the tzinfo argument to the \class{timetz}
constructor, or \code{None} if none was passed.
\end{memberdesc}
Supported operations:
......@@ -1069,13 +1093,13 @@ from a \class{date} object and a \class{timetz} object.
Constructor:
\begin{funcdesc}{datetimetz}{year, month, day,
hour=0, minute=0, second=0, microsecond=0, tzinfo=None}
hour=0, minute=0, second=0, microsecond=0,
tzinfo=None}
The year, month and day arguments are required. \var{tzinfo} may
be \code{None}, or an instance of a \class{tzinfo} subclass. The
remaining arguments may be ints or longs, in the following ranges:
\begin{itemize}
\begin{itemize}
\item \code{MINYEAR <= \var{year} <= MAXYEAR}
\item \code{1 <= \var{month} <= 12}
\item \code{1 <= \var{day} <= number of days in the given month and year}
......@@ -1083,7 +1107,7 @@ Constructor:
\item \code{0 <= \var{minute} < 60}
\item \code{0 <= \var{second} < 60}
\item \code{0 <= \var{microsecond} < 1000000}
\end{itemize}
\end{itemize}
If an argument outside those ranges is given,
\exception{ValueError} is raised.
......@@ -1092,27 +1116,27 @@ Constructor:
Other constructors (class methods):
\begin{funcdesc}{today}{}
\methodline{utcnow}{}
\methodline{utcfromtimestamp}{timestamp}
\methodline{fromordinal}{ordinal}
\methodline{utcnow}{}
\methodline{utcfromtimestamp}{timestamp}
\methodline{fromordinal}{ordinal}
These are the same as the \class{datetime} class methods of the
same names, except that they construct a \class{datetimetz}
object, with tzinfo \code{None}.
\end{funcdesc}
\begin{funcdesc}{now}{\optional{tzinfo=None}}
\methodline{fromtimestamp}{timestamp\optional{, tzinfo=None}}
These are the same as the \class{datetime} class methods of the same names,
except that they accept an additional, optional tzinfo argument, and
construct a \class{datetimetz} object with that \class{tzinfo} object attached.
\methodline{fromtimestamp}{timestamp\optional{, tzinfo=None}}
These are the same as the \class{datetime} class methods of the
same names, except that they accept an additional, optional tzinfo
argument, and construct a \class{datetimetz} object with that
\class{tzinfo} object attached.
\end{funcdesc}
\begin{funcdesc}{combine}{date, time}
This is the same as \method{datetime.combine()}, except that it constructs
a \class{datetimetz} object, and, if the time object is of type timetz,
the \class{datetimetz} object has the same \class{tzinfo} object as the time object.
This is the same as \method{datetime.combine()}, except that it
constructs a \class{datetimetz} object, and, if the time object is
of type timetz, the \class{datetimetz} object has the same
\class{tzinfo} object as the time object.
\end{funcdesc}
Class attributes:
......@@ -1135,31 +1159,37 @@ Class attributes:
Instance attributes, all read-only:
\begin{memberdesc}{year}
Between MINYEAR and MAXYEAR inclusive
Between \constant{MINYEAR} and \constant{MAXYEAR}, inclusive.
\end{memberdesc}
\begin{memberdesc}{month}
Between 1 and 12 inclusive
Between 1 and 12 inclusive
\end{memberdesc}
\begin{memberdesc}{day}
Between 1 and the number of days in the given month
of the given year
Between 1 and the number of days in the given month of the given
year.
\end{memberdesc}
\begin{memberdesc}{hour}
In \code{range(24)}.
In \code{range(24)}.
\end{memberdesc}
\begin{memberdesc}{minute}
In \code{range(60)}.
In \code{range(60)}.
\end{memberdesc}
\begin{memberdesc}{second}
In \code{range(60)}.
In \code{range(60)}.
\end{memberdesc}
\begin{memberdesc}{microsecond}
In \code{range(1000000)}.
In \code{range(1000000)}.
\end{memberdesc}
\begin{memberdesc}{tzinfo}
The object passed as the \var{tzinfo} argument to
the \class{datetimetz} constructor, or \code{None}
if none was passed.
The object passed as the \var{tzinfo} argument to the
\class{datetimetz} constructor, or \code{None} if none was passed.
\end{memberdesc}
Supported operations:
......@@ -1224,16 +1254,15 @@ Supported operations:
Instance methods:
\begin{methoddesc}{date}{}
\methodline{time}{}
\methodline{toordinal}{}
\methodline{weekday}{}
\methodline{isoweekday}{}
\methodline{isocalendar}{}
\methodline{ctime}{}
\methodline{__str__}{}
\methodline{strftime}{format}
These are the same as the \class{datetime} methods of the same names.
\methodline{time}{}
\methodline{toordinal}{}
\methodline{weekday}{}
\methodline{isoweekday}{}
\methodline{isocalendar}{}
\methodline{ctime}{}
\methodline{__str__}{}
\methodline{strftime}{format}
These are the same as the \class{datetime} methods of the same names.
\end{methoddesc}
\begin{methoddesc}{timetz}{}
......@@ -1241,8 +1270,8 @@ These are the same as the \class{datetime} methods of the same names.
and tzinfo.
\end{methoddesc}
\begin{methoddesc}{replace}{year=, month=, day=, hour=, minute=, second=, microsecond=,
tzinfo=}
\begin{methoddesc}{replace}{year=, month=, day=, hour=, minute=, second=,
microsecond=, tzinfo=}
Return a datetimetz with the same value, except for those fields given
new values by whichever keyword arguments are specified. Note that
\code{tzinfo=None} can be specified to create a naive datetimetz from
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment