Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b0e8f5d0
Commit
b0e8f5d0
authored
Dec 30, 2003
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lots of markup adjustments
parent
7c67cb8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
34 deletions
+43
-34
Doc/lib/libdatetime.tex
Doc/lib/libdatetime.tex
+43
-34
No files found.
Doc/lib/libdatetime.tex
View file @
b0e8f5d0
...
@@ -106,7 +106,7 @@ naive or aware. \var{d} is aware if \code{\var{d}.tzinfo} is not
...
@@ -106,7 +106,7 @@ naive or aware. \var{d} is aware if \code{\var{d}.tzinfo} is not
is naive.
is naive.
The distinction between naive and aware doesn't apply to
The distinction between naive and aware doesn't apply to
\c
ode
{
timedelta
}
objects.
\c
lass
{
timedelta
}
objects.
Subclass relationships:
Subclass relationships:
...
@@ -124,11 +124,11 @@ object
...
@@ -124,11 +124,11 @@ object
A
\class
{
timedelta
}
object represents a duration, the difference
A
\class
{
timedelta
}
object represents a duration, the difference
between two dates or times.
between two dates or times.
\begin{classdesc}
{
timedelta
}{
days=0, seconds=0, microseconds=0
,
\begin{classdesc}
{
timedelta
}{
\optional
{
days
\optional
{
, seconds
\optional
{
,
mi
lliseconds=0, minutes=0, hours=0, weeks=0
}
mi
croseconds
\optional
{
, milliseconds
\optional
{
,
minutes
\optional
{
, hours
\optional
{
, weeks
}}}}}}}}
All arguments are optional
. Arguments may be ints, longs, or floats,
All arguments are optional
and default to
\code
{
0
}
. Arguments may
and may be positive or negative.
be ints, longs, or floats,
and may be positive or negative.
Only
\var
{
days
}
,
\var
{
seconds
}
and
\var
{
microseconds
}
are stored
Only
\var
{
days
}
,
\var
{
seconds
}
and
\var
{
microseconds
}
are stored
internally. Arguments are converted to those units:
internally. Arguments are converted to those units:
...
@@ -209,8 +209,8 @@ Supported operations:
...
@@ -209,8 +209,8 @@ Supported operations:
(1)
}
(1)
}
\lineii
{
\var
{
t1
}
=
\var
{
t2
}
-
\var
{
t3
}}
\lineii
{
\var
{
t1
}
=
\var
{
t2
}
-
\var
{
t3
}}
{
Difference of
\var
{
t2
}
and
\var
{
t3
}
.
{
Difference of
\var
{
t2
}
and
\var
{
t3
}
.
Afterwards
\var
{
t1
}
==
\var
{
t2
}
-
\var
{
t3
}
and
\var
{
t2
}
==
\var
{
t1
}
+
\var
{
t3
}
are
Afterwards
\var
{
t1
}
==
\var
{
t2
}
-
\var
{
t3
}
and
true.
\var
{
t2
}
==
\var
{
t1
}
+
\var
{
t3
}
are
true.
(1)
}
(1)
}
\lineii
{
\var
{
t1
}
=
\var
{
t2
}
*
\var
{
i
}
or
\var
{
t1
}
=
\var
{
i
}
*
\var
{
t2
}}
\lineii
{
\var
{
t1
}
=
\var
{
t2
}
*
\var
{
i
}
or
\var
{
t1
}
=
\var
{
i
}
*
\var
{
t2
}}
{
Delta multiplied by an integer or long.
{
Delta multiplied by an integer or long.
...
@@ -352,7 +352,6 @@ Instance attributes (read-only):
...
@@ -352,7 +352,6 @@ Instance attributes (read-only):
Supported operations:
Supported operations:
% XXX rewrite to be a table
\begin{tableii}
{
c|l
}{
code
}{
Operation
}{
Result
}
\begin{tableii}
{
c|l
}{
code
}{
Operation
}{
Result
}
\lineii
{
\var
{
date2
}
=
\var
{
date1
}
+
\var
{
timedelta
}}
\lineii
{
\var
{
date2
}
=
\var
{
date1
}
+
\var
{
timedelta
}}
{
\var
{
date2
}
is
\code
{
\var
{
timedelta
}
.days
}
days removed from
{
\var
{
date2
}
is
\code
{
\var
{
timedelta
}
.days
}
days removed from
...
@@ -366,7 +365,7 @@ Supported operations:
...
@@ -366,7 +365,7 @@ Supported operations:
\lineii
{
\var
{
timedelta
}
=
\var
{
date1
}
-
\var
{
date2
}}
\lineii
{
\var
{
timedelta
}
=
\var
{
date1
}
-
\var
{
date2
}}
{
(3)
}
{
(3)
}
\lineii
{
\var
{
date1
}
<
\var
{
date2
}}
\lineii
{
\var
{
date1
}
<
\var
{
date2
}}
{
\var
{
date1
}
is considered less than
\var
{
date2
}
when
\var
{
date1
}
{
\var
{
date1
}
is considered less than
\var
{
date2
}
when
\var
{
date1
}
precedes
\var
{
date2
}
in time. (4)
}
precedes
\var
{
date2
}
in time. (4)
}
...
@@ -520,9 +519,10 @@ day.
...
@@ -520,9 +519,10 @@ day.
Constructor:
Constructor:
\begin{classdesc}
{
datetime
}{
year, month, day,
\begin{classdesc}
{
datetime
}{
year, month, day
\optional
{
,
hour=0, minute=0, second=0, microsecond=0,
hour
\optional
{
, minute
\optional
{
,
tzinfo=None
}
second
\optional
{
, microsecond
\optional
{
,
tzinfo
}}}}}}
The year, month and day arguments are required.
\var
{
tzinfo
}
may
The year, month and day arguments are required.
\var
{
tzinfo
}
may
be
\code
{
None
}
, or an instance of a
\class
{
tzinfo
}
subclass. The
be
\code
{
None
}
, or an instance of a
\class
{
tzinfo
}
subclass. The
remaining arguments may be ints or longs, in the following ranges:
remaining arguments may be ints or longs, in the following ranges:
...
@@ -550,7 +550,7 @@ Other constructors, all class methods:
...
@@ -550,7 +550,7 @@ Other constructors, all class methods:
See also
\method
{
now()
}
,
\method
{
fromtimestamp()
}
.
See also
\method
{
now()
}
,
\method
{
fromtimestamp()
}
.
\end{methoddesc}
\end{methoddesc}
\begin{methoddesc}
{
now
(tz=None)
}{
}
\begin{methoddesc}
{
now
}{
\optional
{
tz
}
}
Return the current local date and time. If optional argument
Return the current local date and time. If optional argument
\var
{
tz
}
is
\code
{
None
}
or not specified, this is like
\var
{
tz
}
is
\code
{
None
}
or not specified, this is like
\method
{
today()
}
, but, if possible, supplies more precision than can
\method
{
today()
}
, but, if possible, supplies more precision than can
...
@@ -572,7 +572,7 @@ Other constructors, all class methods:
...
@@ -572,7 +572,7 @@ Other constructors, all class methods:
See also
\method
{
now()
}
.
See also
\method
{
now()
}
.
\end{methoddesc}
\end{methoddesc}
\begin{methoddesc}
{
fromtimestamp
}{
timestamp
, tz=None
}
\begin{methoddesc}
{
fromtimestamp
}{
timestamp
\optional
{
, tz
}
}
Return the local date and time corresponding to the
\POSIX
{}
Return the local date and time corresponding to the
\POSIX
{}
timestamp, such as is returned by
\function
{
time.time()
}
.
timestamp, such as is returned by
\function
{
time.time()
}
.
If optional argument
\var
{
tz
}
is
\code
{
None
}
or not specified, the
If optional argument
\var
{
tz
}
is
\code
{
None
}
or not specified, the
...
@@ -780,8 +780,10 @@ Instance methods:
...
@@ -780,8 +780,10 @@ Instance methods:
and tzinfo members. See also method
\method
{
time()
}
.
and tzinfo members. See also method
\method
{
time()
}
.
\end{methoddesc}
\end{methoddesc}
\begin{methoddesc}
{
replace
}{
year=, month=, day=, hour=, minute=, second=,
\begin{methoddesc}
{
replace
}{
\optional
{
year
\optional
{
, month
\optional
{
,
microsecond=, tzinfo=
}
day
\optional
{
, hour
\optional
{
, minute
\optional
{
,
second
\optional
{
, microsecond
\optional
{
,
tzinfo
}}}}}}}}}
Return a datetime with the same members, except for those members given
Return a datetime with the same members, except for those members given
new values by whichever keyword arguments are specified. Note that
new values by whichever keyword arguments are specified. Note that
\code
{
tzinfo=None
}
can be specified to create a naive datetime from
\code
{
tzinfo=None
}
can be specified to create a naive datetime from
...
@@ -911,7 +913,7 @@ Instance methods:
...
@@ -911,7 +913,7 @@ Instance methods:
same as
\code
{
self.date().isocalendar()
}
.
same as
\code
{
self.date().isocalendar()
}
.
\end{methoddesc}
\end{methoddesc}
\begin{methoddesc}
{
isoformat
}{
sep='T'
}
\begin{methoddesc}
{
isoformat
}{
\optional
{
sep
}
}
Return a string representing the date and time in ISO 8601 format,
Return a string representing the date and time in ISO 8601 format,
YYYY-MM-DDTHH:MM:SS.mmmmmm
YYYY-MM-DDTHH:MM:SS.mmmmmm
or, if
\member
{
microsecond
}
is 0,
or, if
\member
{
microsecond
}
is 0,
...
@@ -967,8 +969,8 @@ Instance methods:
...
@@ -967,8 +969,8 @@ Instance methods:
A time object represents a (local) time of day, independent of any
A time object represents a (local) time of day, independent of any
particular day, and subject to adjustment via a
\class
{
tzinfo
}
object.
particular day, and subject to adjustment via a
\class
{
tzinfo
}
object.
\begin{classdesc}
{
time
}{
hour
=0, minute=0, second=0, microsecond=0
,
\begin{classdesc}
{
time
}{
hour
\optional
{
, minute
\optional
{
, second
\optional
{
,
tzinfo=None
}
microsecond
\optional
{
, tzinfo
}}}}
}
All arguments are optional.
\var
{
tzinfo
}
may be
\code
{
None
}
, or
All arguments are optional.
\var
{
tzinfo
}
may be
\code
{
None
}
, or
an instance of a
\class
{
tzinfo
}
subclass. The remaining arguments
an instance of a
\class
{
tzinfo
}
subclass. The remaining arguments
may be ints or longs, in the following ranges:
may be ints or longs, in the following ranges:
...
@@ -981,7 +983,8 @@ particular day, and subject to adjustment via a \class{tzinfo} object.
...
@@ -981,7 +983,8 @@ particular day, and subject to adjustment via a \class{tzinfo} object.
\end{itemize}
\end{itemize}
If an argument outside those ranges is given,
If an argument outside those ranges is given,
\exception
{
ValueError
}
is raised.
\exception
{
ValueError
}
is raised. All default to
\code
{
0
}
except
\var
{
tzinfo
}
, which defaults to
\constant
{
None
}
.
\end{classdesc}
\end{classdesc}
Class attributes:
Class attributes:
...
@@ -1057,7 +1060,9 @@ Supported operations:
...
@@ -1057,7 +1060,9 @@ Supported operations:
Instance methods:
Instance methods:
\begin{methoddesc}
{
replace
}
(hour=, minute=, second=, microsecond=, tzinfo=)
\begin{methoddesc}
{
replace
}{
\optional
{
hour
\optional
{
, minute
\optional
{
,
second
\optional
{
, microsecond
\optional
{
,
tzinfo
}}}}}}
Return a
\class
{
time
}
with the same value, except for those members given
Return a
\class
{
time
}
with the same value, except for those members given
new values by whichever keyword arguments are specified. Note that
new values by whichever keyword arguments are specified. Note that
\code
{
tzinfo=None
}
can be specified to create a naive
\class
{
time
}
from
\code
{
tzinfo=None
}
can be specified to create a naive
\class
{
time
}
from
...
@@ -1183,7 +1188,7 @@ implement all of them.
...
@@ -1183,7 +1188,7 @@ implement all of them.
\code
{
\var
{
tz
}
.utcoffset(
\var
{
dt
}
) -
\var
{
tz
}
.dst(
\var
{
dt
}
)
}
\code
{
\var
{
tz
}
.utcoffset(
\var
{
dt
}
) -
\var
{
tz
}
.dst(
\var
{
dt
}
)
}
must return the same result for every
\class
{
datetime
}
\var
{
dt
}
must return the same result for every
\class
{
datetime
}
\var
{
dt
}
with
\code
{
\var
{
dt
}
.tzinfo
==
\var
{
tz
}}
For sane
\class
{
tzinfo
}
with
\code
{
\var
{
dt
}
.tzinfo
==
\var
{
tz
}}
For sane
\class
{
tzinfo
}
subclasses, this expression yields the time zone's "standard offset",
subclasses, this expression yields the time zone's "standard offset",
which should not depend on the date or the time, but only on geographic
which should not depend on the date or the time, but only on geographic
location. The implementation of
\method
{
datetime.astimezone()
}
relies
location. The implementation of
\method
{
datetime.astimezone()
}
relies
...
@@ -1197,18 +1202,23 @@ implement all of them.
...
@@ -1197,18 +1202,23 @@ implement all of them.
of these two:
of these two:
\begin{verbatim}
\begin{verbatim}
return timedelta(0) # a fixed-offset class: doesn't account for DST
def dst(self):
# a fixed-offset class: doesn't account for DST
return timedelta(0)
\end{verbatim}
or
or
# Code to set dston and dstoff to the time zone's DST transition
\begin{verbatim}
# times based on the input dt.year, and expressed in standard local
def dst(self):
# time. Then
# Code to set dston and dstoff to the time zone's DST
# transition times based on the input dt.year, and expressed
if dston <= dt.replace(tzinfo=None) < dstoff:
# in standard local time. Then
return timedelta(hours=1)
else:
if dston <= dt.replace(tzinfo=None) < dstoff:
return timedelta(0)
return timedelta(hours=1)
else:
return timedelta(0)
\end{verbatim}
\end{verbatim}
The default implementation of
\method
{
dst()
}
raises
The default implementation of
\method
{
dst()
}
raises
...
@@ -1321,7 +1331,7 @@ April, and ends the minute after 1:59 (EDT) on the last Sunday in October:
...
@@ -1321,7 +1331,7 @@ April, and ends the minute after 1:59 (EDT) on the last Sunday in October:
When DST starts (the "start" line), the local wall clock leaps from 1:59
When DST starts (the "start" line), the local wall clock leaps from 1:59
to 3:00. A wall time of the form 2:MM doesn't really make sense on that
to 3:00. A wall time of the form 2:MM doesn't really make sense on that
day, so
\code
{
astimezone(Eastern)
}
won't deliver a result with
day, so
\code
{
astimezone(Eastern)
}
won't deliver a result with
\code
{
hour
==
2
}
on the
\code
{
hour
==
2
}
on the
day DST begins. In order for
\method
{
astimezone()
}
to make this
day DST begins. In order for
\method
{
astimezone()
}
to make this
guarantee, the
\method
{
rzinfo.dst()
}
method must consider times
guarantee, the
\method
{
rzinfo.dst()
}
method must consider times
in the "missing hour" (2:MM for Eastern) to be in daylight time.
in the "missing hour" (2:MM for Eastern) to be in daylight time.
...
@@ -1398,4 +1408,3 @@ C standard added additional format codes.
...
@@ -1398,4 +1408,3 @@ C standard added additional format codes.
The exact range of years for which
\method
{
strftime()
}
works also
The exact range of years for which
\method
{
strftime()
}
works also
varies across platforms. Regardless of platform, years before 1900
varies across platforms. Regardless of platform, years before 1900
cannot be used.
cannot be used.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment