[Python-checkins] python/nondist/sandbox/datetime doc.txt,NONE,1.1
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
2002年12月03日 14:54:25 -0800
Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv18468
Added Files:
doc.txt
Log Message:
Started writing some docs. This is intended to be definitive, so if
something here isn't clear, or is wrong, change it.
--- NEW FILE: doc.txt ---
The datetime module supplies a number of classes for manipulating dates
and times, in both simple and complex ways.
class date
year, month, and day
This is an idealized date, assuming the current Gregorian calendar
always was, and always will be, in effect.
class time
hour, minute, second, and microsecond
This is independent of any particular day.
class datetime
year, month, day, hour, minute, second, and microsecond
This has no concept of timezone or daylight savings time. You
can think of a datetime object as representing UTC time, or local
time, or whatever else is convenient.
class datetimetz
Like datetime, but also supports a customizable notion of time
adjustment (for timezones, or daylight savings time, or any other
computable adjustment)
class timetz
Like time, but also supports a customizable notion of time
adjustment.
class timedelta
A duration, the difference between two datetimes, to microsecond
resolution.
Objects of these types are immutable.
class timedelta
===============
A timedelta object represents a duration, the difference between two
datetimes.
Constructor:
timedelta(days=0, seconds=0, microseconds=0,
# The following should only be used as keyword args:
milliseconds=0, minutes=0, hours=0, weeks=0)
All arguments are optional. Arguments may be ints, longs, or floats,
and may be positive or negative.
Only days, seconds and microseconds are stored internally. Arguments
are converted to those units:
A millisecond is converted 1000 microseconds.
A minute is converted to 60 seconds.
An hour is converted to 3600 seconds.
A week is converted to 7 days.
and days, seconds and microseconds are normalized so that
0 <= microseconds < 1000000
0 <= seconds < 3600*24 (the number of seconds in one day)
-999999999 <= days <= 999999999
If any argument is a float, and there are fractional microseconds,
the value retained is rounded to the nearest microsecond.
If the normalized value of days lies outside the indicated range,
OverflowError is raised.
Class attributes:
.min
The most negative timedelta object, timedelta(-999999999).
.max
The most positive timedelta object,
timedelta(days=999999999, hours=23, minutes=59, seconds=59,
microseconds=999999)
.resolution
The smallest possible difference between non-equal timedelta
objects, timedelta(microseconds=1).
Instance attributes (read-only):
.days between -999999999 and 999999999 inclusive
.seconds between 0 and 86399 inclusive
.microseconds between 0 and 999999 inclusive
Supported operations:
- timedelta + timedelta -> timedelta
This is exact, but may overflow.
- timedelta - timedelta -> timedelta
This is exact, but may overflow.
- timedelta * (int or long) -> timedelta
This is exact, but may overflow.
- timedelta // (int or long) -> timedelta
The floor is computed and the remainder (if any) is thrown away.
Division by 0 raises ZeroDivisionError.
- unary plus, minus, abs
These are exact, but unary minus and abs may overflow.
- comparison of timedelta to timedelta
- hash, use as dict key
- pickling
In addition, subtraction of two datetime objects returns a timedelta,
and addition or subtraction of a datetime and a timedelta returns a
datetime.
class date
==========
class datetime
==============
class datetimetz
================
class time
==========
class timetz
============