Commit 2daa5789 authored by 's avatar

Cleaned up docs ;)

parent d4093c24
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
"""Encapsulation of date/time values""" """Encapsulation of date/time values"""
__version__='$Revision: 1.7 $'[11:-2] __version__='$Revision: 1.8 $'[11:-2]
import sys,os,regex,DateTimeZone import sys,os,regex,DateTimeZone
...@@ -198,14 +198,15 @@ class _cache: ...@@ -198,14 +198,15 @@ class _cache:
class DateTime: class DateTime:
"""DateTime objects represent instants in time and provide a """DateTime objects represent instants in time and provide
rich interface for controlling its representation without interfaces for controlling its representation without
affecting the absolute value of the object. affecting the absolute value of the object.
DateTime objects may be created from a wide variety of string DateTime objects may be created from a wide variety of string
or numeric data, or may be computed from other DateTime objects. or numeric data, or may be computed from other DateTime objects.
DateTimes support conversion to and from most major timezones DateTimes support the ability to convert their representations
without affecting the absolute value of the object. to many major timezones, as well as the ablility to create a
DateTime object in the context of a given timezone.
DateTime objects provide partial numerical behavior: DateTime objects provide partial numerical behavior:
...@@ -226,9 +227,13 @@ class DateTime: ...@@ -226,9 +227,13 @@ class DateTime:
object. object.
DateTime objects may be converted to integer, long, or float DateTime objects may be converted to integer, long, or float
numbers of days since January 1, 1900, using the standard int, numbers of days since January 1, 1901, using the standard int,
long, and float functions, and provide access to the objects value long, and float functions (Compatibility Note: int, long and
in a float format usable with the python time module. float return the number of days since 1901 in GMT rather than
local machine timezone). DateTime objects also provide access
to their value in a float format usable with the python time
module, provided that the value of the object falls in the
range of the epoch-based time module.
A DateTime object should be considered immutable; all conversion A DateTime object should be considered immutable; all conversion
and numeric operations return a new DateTime object rather than and numeric operations return a new DateTime object rather than
...@@ -239,24 +244,27 @@ class DateTime: ...@@ -239,24 +244,27 @@ class DateTime:
A DateTime object always maintains its value as an absolute A DateTime object always maintains its value as an absolute
UTC time, and is represented in the context of some timezone UTC time, and is represented in the context of some timezone
based on the arguments used to create the object. Most of a based on the arguments used to create the object. A DateTime
DateTime object's methods return values based on the timezone object's methods return values based on the timezone context.
context: if a DateTime was created using the local machine\'s
timezone, calling DayOfWeek() on the object will return the
day of the week in the context of the local machine\'s timezone.
DateTimes may be created with from zero to seven arguments.
Note that in all cases the local machine timezone is used for Note that in all cases the local machine timezone is used for
representation if no timezone is specified. representation if no timezone is specified.
DateTimes may be created with from zero to seven arguments.
- If the function is called with no arguments, then the - If the function is called with no arguments, then the
current date/time is returned, represented in the timezone current date/time is returned, represented in the
of the local machine. timezone of the local machine.
- If the function is invoked with a single string argument
which is a recognized timezone name, an object representing
the current time is returned, represented in the specified
timezone.
- If the function is invoked with a single string argument, - If the function is invoked with a single string argument
it should be either a string naming the timezone representation representing a valid date/time, an object representing
the object should use, or a string representing a valid that date/time will be returned.
date/time value.
As a general rule, any date-time representation that is As a general rule, any date-time representation that is
recognized and unambigous to a resident of North America is recognized and unambigous to a resident of North America is
...@@ -276,14 +284,14 @@ class DateTime: ...@@ -276,14 +284,14 @@ class DateTime:
that timezone) that timezone)
<PRE> <PRE>
e=DateTime('US/Eastern') e=DateTime('US/Eastern')
# returns current date/time, represented in US/Eastern. # returns current date/time, represented in US/Eastern.
x=DateTime('1997/3/9 1:45pm') x=DateTime('1997/3/9 1:45pm')
# returns specified time, represented in local machine zone. # returns specified time, represented in local machine zone.
y=DateTime('Mar 9, 1997 13:45:00') y=DateTime('Mar 9, 1997 13:45:00')
# y is equal to x # y is equal to x
</PRE> </PRE>
...@@ -316,24 +324,26 @@ class DateTime: ...@@ -316,24 +324,26 @@ class DateTime:
- If the DateTime function is invoked with a single - If the DateTime function is invoked with a single
Numeric argument, the number is assumed to be either Numeric argument, the number is assumed to be either
a floating point value such as that returned by a floating point value such as that returned by
time.time() , or a number of days after time.time() , or a number of days after January 1, 1901
January 1, 1901 00:00:00 UTC. 00:00:00 UTC.
A DateTime object is returned that represents either A DateTime object is returned that represents either
the value of the time.time() float, or that is that the gmt value of the time.time() float represented in
number of days after January 1, 1900 00:00:00 UTC, the local machine's timezone, or that number of days
represented in the timezone of the local machine. A after January 1, 1901. Note that the number of days
negative argument will yield a date-time value before 1900. after 1901 need to be expressed from the viewpoint of
the local machine's timezone. A negative argument will
yield a date-time value before 1901.
- If the function is invoked with two numeric arguments, - If the function is invoked with two numeric arguments,
then the first is taken to be an integer year and the then the first is taken to be an integer year and the
second argument is taken to be an offset in days from second argument is taken to be an offset in days from
the beginning of the year (in UTC). the beginning of the year, in the context of the local
machine timezone.
The date-time value returned is the given offset number of The date-time value returned is the given offset number of
days from the beginning of the given year, represented in days from the beginning of the given year, represented in
the timezone of the local machine. The offset may be positive the timezone of the local machine. The offset may be positive
or negative. This form of the function is commonly used or negative.
to convert a year and julean day to a date-time value.
Two-digit years are assumed to be in the twentieth Two-digit years are assumed to be in the twentieth
century. century.
...@@ -344,17 +354,17 @@ class DateTime: ...@@ -344,17 +354,17 @@ class DateTime:
with a value of that gmt time will be returned, represented with a value of that gmt time will be returned, represented
in the given timezone. in the given timezone.
<PRE> <PRE>
import time import time
t=time.time() t=time.time()
now_east=DateTime(t,'US/Eastern') now_east=DateTime(t,'US/Eastern')
# Time t represented as US/Eastern # Time t represented as US/Eastern
now_west=DateTime(t,'US/Pacific') now_west=DateTime(t,'US/Pacific')
# Time t represented as US/Pacific # Time t represented as US/Pacific
# now_east == now_west # now_east == now_west
# only their representations are different # only their representations are different
</PRE> </PRE>
...@@ -368,11 +378,9 @@ class DateTime: ...@@ -368,11 +378,9 @@ class DateTime:
sixth arguments are floating point, positive or sixth arguments are floating point, positive or
negative offsets in units of hours, minutes, and days, negative offsets in units of hours, minutes, and days,
and default to zero if not given. An optional string may and default to zero if not given. An optional string may
be given as the final argument to indicate timezone. be given as the final argument to indicate timezone (the
A DateTime object corresponding to the given year, month effect of this is as if you had taken the value of time.time()
and day, offset by the given hours, minutes, and seconds at that time on a machine in the specified timezone).
in context of either the indicated timezone or the timezone
of the local machine if no timezone is given.
In all cases, invalid date, time, or timezone components will In all cases, invalid date, time, or timezone components will
raise a DateTimeError. raise a DateTimeError.
...@@ -794,7 +802,7 @@ class DateTime: ...@@ -794,7 +802,7 @@ class DateTime:
in the format used by the python time module. in the format used by the python time module.
Note that it is possible to create date/time values Note that it is possible to create date/time values
with DateTime that have no meaningful value to the with DateTime that have no meaningful value to the
time module, and in such cases a DateTimeError is time module, and in such cases a DateTimeError is
raised. A DateTime object\'s value must generally be raised. A DateTime object\'s value must generally be
between Jan 1, 1970 (or your local machine epoch) and between Jan 1, 1970 (or your local machine epoch) and
Jan 2038 to produce a valid time.time() style value.""" Jan 2038 to produce a valid time.time() style value."""
......
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