Method Summary |
|
__init__ (self,
*args,
**kw)
Return a new date-time object |
|
__add__ (self,
other)
A DateTime may be added to a number and a number may be added to a
DateTime; two DateTimes cannot be added. |
|
__cmp__ (self,
obj)
Compare a DateTime with another DateTime object, or a float such as
those returned by time.time(). |
|
__eq__ (self,
t)
Compare this DateTime object to another DateTime object OR a floating
point number such as that which is returned by the python time
module. |
|
__float__ (self)
Convert to floating-point number of seconds since the epoch (gmt) |
|
__ge__ (self,
t)
Compare this DateTime object to another DateTime object OR a floating
point number such as that which is returned by the python time
module. |
|
__getattr__(self,
name)
|
|
__getinitargs__(self)
|
|
__gt__ (self,
t)
Compare this DateTime object to another DateTime object OR a floating
point number such as that which is returned by the python time
module. |
|
__hash__ (self)
Compute a hash value for a DateTime |
|
__int__ (self)
Convert to an integer number of seconds since the epoch (gmt) |
|
__le__ (self,
t)
Compare this DateTime object to another DateTime object OR a floating
point number such as that which is returned by the python time
module. |
|
__long__ (self)
Convert to a long-int number of seconds since the epoch (gmt) |
|
__lt__ (self,
t)
Compare this DateTime object to another DateTime object OR a floating
point number such as that which is returned by the python time
module. |
|
__ne__ (self,
t)
Compare this DateTime object to another DateTime object OR a floating
point number such as that which is returned by the python time
module. |
|
__radd__ (self,
other)
A DateTime may be added to a number and a number may be added to a
DateTime; two DateTimes cannot be added. |
|
__repr__ (self)
Convert a DateTime to a string that looks like a Python
expression. |
|
__str__ (self)
Convert a DateTime to a string. |
|
__sub__ (self,
other)
Either a DateTime or a number may be subtracted from a DateTime,
however, a DateTime may not be subtracted from a number. |
|
aCommon (self)
Return a string representing the object's value in the format: Mar 1,
1997 1:45 pm |
|
aCommonZ (self)
Return a string representing the object's value in the format: Mar 1,
1997 1:45 pm US/Eastern |
|
aDay (self)
Return the abreviated name of the day of the week |
|
aMonth (self)
Return the abreviated month name. |
|
AMPM (self)
Return the time string for an object to the nearest second. |
|
ampm (self)
Return the appropriate time modifier (am or pm) |
|
AMPMMinutes (self)
Return the time string for an object not showing seconds. |
|
Date (self)
Return the date string for the object. |
|
Day (self)
Return the full name of the day of the week |
|
day (self)
Return the integer day |
|
Day_ (self)
Compatibility: see pDay |
|
DayOfWeek (self)
Compatibility: see Day |
|
dayOfYear (self)
Return the day of the year, in context of the timezone representation
of the object |
|
dd (self)
Return day as a 2 digit string |
|
dow (self)
Return the integer day of the week, where sunday is 0 |
|
dow_1 (self)
Return the integer day of the week, where sunday is 1 |
|
earliestTime (self)
Return a new DateTime object that represents the earliest possible
time (in whole seconds) that still falls within the current object's day,
in the object's timezone context |
|
equalTo (self,
t)
Compare this DateTime object to another DateTime object OR a floating
point number such as that which is returned by the python time
module. |
|
fCommon (self)
Return a string representing the object's value in the format: March
1, 1997 1:45 pm |
|
fCommonZ (self)
Return a string representing the object's value in the format: March
1, 1997 1:45 pm US/Eastern |
|
greaterThan (self,
t)
Compare this DateTime object to another DateTime object OR a floating
point number such as that which is returned by the python time
module. |
|
greaterThanEqualTo (self,
t)
Compare this DateTime object to another DateTime object OR a floating
point number such as that which is returned by the python time
module. |
|
h_12 (self)
Return the 12-hour clock representation of the hour |
|
h_24 (self)
Return the 24-hour clock representation of the hour |
|
hour (self)
Return the 24-hour clock representation of the hour |
|
HTML4 (self)
Return the object in the format used in the HTML4.0 specification,
one of the standard forms in ISO8601. |
|
isCurrentDay (self)
Return true if this object represents a date/time that falls within
the current day, in the context of this object's timezone
representation |
|
isCurrentHour (self)
Return true if this object represents a date/time that falls within
the current hour, in the context of this object's timezone
representation |
|
isCurrentMinute (self)
Return true if this object represents a date/time that falls within
the current minute, in the context of this object's timezone
representation |
|
isCurrentMonth (self)
Return true if this object represents a date/time that falls within
the current month, in the context of this object's timezone
representation |
|
isCurrentYear (self)
Return true if this object represents a date/time that falls within
the current year, in the context of this object's timezone
representation |
|
isFuture (self)
Return true if this object represents a date/time later than the time
of the call |
|
isLeapYear (self)
Return true if the current year (in the context of the object's
timezone) is a leap year |
|
ISO (self)
Return the object in ISO standard format. |
|
ISO8601 (self)
Return the object in ISO 8601-compatible format containing
the date, time with seconds-precision and the time zone
identifier - see http://www.w3.org/TR/NOTE-datetime
Dates are output as: YYYY-MM-DDTHH:MM:SSTZD
T is a literal character. |
|
isPast (self)
Return true if this object represents a date/time earlier than the
time of the call |
|
JulianDay (self)
Return the Julian day according to
http://www.tondering.dk/claus/cal/node3.html#sec-calcjd |
|
latestTime (self)
Return a new DateTime object that represents the latest possible time
(in whole seconds) that still falls within the current object's day, in
the object's timezone context |
|
lessThan (self,
t)
Compare this DateTime object to another DateTime object OR a floating
point number such as that which is returned by the python time
module. |
|
lessThanEqualTo (self,
t)
Compare this DateTime object to another DateTime object OR a floating
point number such as that which is returned by the python time
module. |
|
localZone (self,
ltm)
Returns the time zone on the given date. |
|
millis (self)
Return the millisecond since the epoch in GMT. |
|
minute (self)
Return the minute |
|
mm (self)
Return month as a 2 digit string |
|
Mon (self)
Compatibility: see aMonth |
|
Mon_ (self)
Compatibility: see pMonth |
|
Month (self)
Return the full month name |
|
month (self)
Return the month of the object as an integer |
|
notEqualTo (self,
t)
Compare this DateTime object to another DateTime object OR a floating
point number such as that which is returned by the python time
module. |
|
parts (self)
Return a tuple containing the calendar year, month, day, hour, minute
second and timezone of the object |
|
pCommon (self)
Return a string representing the object's value in the format:
Mar. |
|
pCommonZ (self)
Return a string representing the object's value in the format:
Mar. |
|
pDay (self)
Return the abreviated (with period) name of the day of the week |
|
pMonth (self)
Return the abreviated (with period) month name. |
|
PreciseAMPM (self)
Return the time string for the object. |
|
PreciseTime (self)
Return the time string for the object. |
|
rfc822 (self)
Return the date in RFC 822 format |
|
second (self)
Return the second |
|
strftime(self,
format)
|
|
Time (self)
Return the time string for an object to the nearest second. |
|
TimeMinutes (self)
Return the time string for an object not showing seconds. |
|
timeTime (self)
Return the date/time as a floating-point number in UTC, in the format
used by the python time module. |
|
timezone (self)
Return the timezone in which the object is represented. |
|
toZone (self,
z)
Return a DateTime with the value as the current object, represented in
the indicated timezone. |
|
tzoffset (self)
Return the timezone offset for the objects timezone. |
|
week (self)
Return the week number according to ISO see
http://www.tondering.dk/claus/cal/node6.html#SECTION00670000000000000000 |
|
year (self)
Return the calendar year of the object |
|
yy (self)
Return calendar year as a 2 digit string |
|
__parse_iso8601 (self,
s)
parse an ISO 8601 compliant date |
|
_calcTimezoneName(self,
x,
ms)
|
|
_parse(self,
st,
datefmt)
|
|
_parse_args (self,
*args,
**kw)
Return a new date-time object |
|
_parse_iso8601(self,
s)
|
|
_upgrade_old (self)
Upgrades a previously pickled DateTime object. |
|
_validDate(self,
y,
m,
d)
|
|
_validTime(self,
h,
m,
s)
|
Class Variable Summary |
int |
__allow_access_to_unprotected_subobjects__ = 1 |
NoneType |
__roles__ = None |
classobj |
DateError = DateTime.DateTime.DateError |
classobj |
DateTimeError = DateTime.DateTime.DateTimeError |
str |
delimiters = '-/.:,+'
|
SRE_Pattern |
flt_pattern = :([0-9]+\.[0-9]+)
|
SRE_Pattern |
int_pattern = ([0-9]+)
|
SRE_Pattern |
name_pattern = ([a-zA-Z]+)
|
str |
space_chars = ' \t\n'
|
classobj |
SyntaxError = DateTime.DateTime.SyntaxError |
classobj |
TimeError = DateTime.DateTime.TimeError |
dict |
_daymap = {'saturday': 7, 'thu': 5, 'monday': 2, 'wed': ...
|
list |
_days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Th...
|
list |
_days_a = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sa...
|
list |
_days_p = ['Sun.', 'Mon.', 'Tue.', 'Wed.', 'Thu.', 'Fri....
|
int |
_isDST = 1 |
str |
_localzone = 'GMT-4'
|
str |
_localzone0 = 'US/Eastern'
|
str |
_localzone1 = 'GMT-4'
|
tuple |
_month_len = ((0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31...
|
dict |
_monthmap = {'sep': 9, 'apr': 4, 'december': 12, 'july':...
|
list |
_months = ['', 'January', 'February', 'March', 'April', ...
|
list |
_months_a = ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun...
|
list |
_months_p = ['', 'Jan.', 'Feb.', 'Mar.', 'Apr.', 'May', ...
|
bool |
_multipleZones = True
|
_cache |
_tzinfo = <DateTime.DateTime._cache instance at 0x1169d5...
|
tuple |
_until_month = ((0, 0, 31, 59, 90, 120, 151, 181, 212, 2...
|
_parse_args(self,
*args,
**kw)
Return a new date-time object
A DateTime object always maintains its value as an absolute UTC
time, and is represented in the context of some timezone based on the
arguments used to create the object. A DateTime object's methods return
values based on the timezone context.
Note that in all cases the local machine timezone is used for
representation if no timezone is specified.
DateTimes may be created with from zero to seven arguments.
-
If the function is called with no arguments or with None, then
the current date/time is returned, represented in the 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
representing a valid date/time, an object representing that
date/time will be returned.
As a general rule, any date-time representation that is
recognized and unambigous to a resident of North America is
acceptable.(The reason for this qualification is that in North
America, a date like: 2/1/1994 is interpreted as February 1, 1994,
while in some parts of the world, it is interpreted as January 2,
1994.) A date/time string consists of two components, a date
component and an optional time component, separated by one or more
spaces. If the time component is omited, 12:00am is assumed. Any
recognized timezone name specified as the final element of the
date/time string will be used for computing the date/time value.
(If you create a DateTime with the string 'Mar 9, 1997 1:45pm
US/Pacific', the value will essentially be the same as if you had
captured time.time() at the specified date and time on a machine in
that timezone) <PRE>
e=DateTime('US/Eastern') # returns current date/time,
represented in US/Eastern.
x=DateTime('1997/3/9 1:45pm') # returns specified time,
represented in local machine zone.
y=DateTime('Mar 9, 1997 13:45:00') # y is equal to x
</PRE>
New in Zope 2.4: The DateTime constructor automatically detects
and handles ISO8601 compliant dates (YYYY-MM-DDThh:ss:mmTZD). See
http://www.w3.org/TR/NOTE-datetime for full specs.
The date component consists of year, month, and day values. The
year value must be a one-, two-, or four-digit integer. If a one-
or two-digit year is used, the year is assumed to be in the
twentieth century. The month may an integer, from 1 to 12, a month
name, or a month abreviation, where a period may optionally follow
the abreviation. The day must be an integer from 1 to the number of
days in the month. The year, month, and day values may be separated
by periods, hyphens, forward, shashes, or spaces. Extra spaces are
permitted around the delimiters. Year, month, and day values may be
given in any order as long as it is possible to distinguish the
components. If all three components are numbers that are less than
13, then a a month-day-year ordering is assumed.
The time component consists of hour, minute, and second values
separated by colons. The hour value must be an integer between 0
and 23 inclusively. The minute value must be an integer between 0
and 59 inclusively. The second value may be an integer value
between 0 and 59.999 inclusively. The second value or both the
minute and second values may be ommitted. The time may be followed
by am or pm in upper or lower case, in which case a 12-hour clock
is assumed.
-
If the DateTime function is invoked with a single Numeric
argument, the number is assumed to be a floating point value such
as that returned by time.time().
A DateTime object is returned that represents the gmt value of
the time.time() float represented in the local machine's
timezone.
-
If the DateTime function is invoked with a single argument that
is a DateTime instane, a copy of the passed object will be
created.
-
If the function is invoked with two numeric arguments, then the
first is taken to be an integer year and the second argument is
taken to be an offset in days from the beginning of the year, in
the context of the local machine timezone. The date-time value
returned is the given offset number of days from the beginning of
the given year, represented in the timezone of the local machine.
The offset may be positive or negative. Two-digit years are assumed
to be in the twentieth century.
-
If the function is invoked with two arguments, the first a float
representing a number of seconds past the epoch in gmt (such as
those returned by time.time()) and the second a string naming a
recognized timezone, a DateTime with a value of that gmt time will
be returned, represented in the given timezone. <PRE> import
time t=time.time()
now_east=DateTime(t,'US/Eastern') # Time t represented as
US/Eastern
now_west=DateTime(t,'US/Pacific') # Time t represented as
US/Pacific
# now_east == now_west # only their representations are
different
</PRE>
-
If the function is invoked with three or more numeric arguments,
then the first is taken to be an integer year, the second is taken
to be an integer month, and the third is taken to be an integer
day. If the combination of values is not valid, then a DateError is
raised. Two-digit years are assumed to be in the twentieth century.
The fourth, fifth, and sixth arguments specify a time in hours,
minutes, and seconds; hours and minutes should be positive integers
and seconds is a positive floating point value, all of these
default to zero if not given. An optional string may be given as
the final argument to indicate timezone (the effect of this is as
if you had taken the value of time.time() at that time on a machine
in the specified timezone).
New in Zope 2.7: A new keyword parameter "datefmt" can
be passed to the constructor. If set to "international",
the constructor is forced to treat ambigious dates as "days
before month before year". This useful if you need to parse
non-US dates in a reliable way
In any case that a floating point number of seconds is given or
derived, it's rounded to the nearest millisecond.
If a string argument passed to the DateTime constructor cannot be
parsed, it will raise DateTime.SyntaxError. Invalid date components
will raise a DateError, while invalid time or timezone components will
raise a DateTimeError.
The module function Timezones() will return a list of the timezones
recognized by the DateTime module. Recognition of timezone names is
case-insensitive.
-
|