| |
- DaysInMonth
- datetime
-
- date
- time
class DaysInMonth |
|
Simple class to correctly calculate the days in a month in Python 2.2.
The calendar.monthrange(year, month) fails in that version. |
|
Methods defined here:
- calculate(self, year, month)
- isleap(self, year)
- Return 1 for leap years, 0 for non-leap years.
- test(self)
- weekday(self, year, month, day)
- Return weekday (0-6 ~ Mon-Sun) for year (1970-...), month (1-12), day (1-31).
|
class date(datetime) |
|
Constructs an object holding a date value.
Is just another name binding for DateTime().
The time part is set to '00:00:00.00'. |
|
Methods defined here:
- __init__(self, year, month, day)
- __repr__(self)
- Return a string representation of the object.
- isoformat(self)
- Return the date as a standard SQL string of the format 'YYYY-MM-DD'.
- now(self)
- Return the current date and time as a datetime.
- timetuple(self)
- Returns the date as a python tuple as constructed by time.localtime().
WARNING: The last 6 entries in the tuple are obtained from time.localtime()
and do not represent anything.
Methods inherited from datetime:
- __cmp__(self, other)
- __eq__(self, other)
- __getitem__(self, item)
- Enable dictionary-style attribute reading for year, month, day, hour, minute and second.
- __ne__(self, other)
- __str__(self)
- Return the object as standard SQL.
- strftime(self, format)
- Format the time using standard time module string format strings.
%a Locale's abbreviated weekday name.
%A Locale's full weekday name.
%b Locale's abbreviated month name.
%B Locale's full month name.
%c Locale's appropriate date and time representation.
%d Day of the month as a decimal number [01, 31].
%H Hour (24-hour clock) as a decimal number [00, 23].
%I Hour (12-hour clock) as a decimal number [01, 12].
%j Day of the year as a decimal number [001, 366].
%m Month as a decimal number [01, 12].
%M Minute as a decimal number [00, 59].
%p Locale's equivalent of either AM or PM.
%S Second as a decimal number [00, 61]. (1)
%U Week number of the year (Sunday as the first day of the week)
as a decimal number [00, 53]. All days in a new year preceding
the first Sunday are considered to be in week 0.
%w Weekday as a decimal number [0(Sunday), 6].
%W Week number of the year (Monday as the first day of the week)
as a decimal number [00, 53]. All days in a new year preceding
the first Monday are considered to be in week 0.
%x Locale's appropriate date representation.
%X Locale's appropriate time representation.
%y Year without century as a decimal number [00, 99].
%Y Year with century as a decimal number.
%Z Time zone name (no characters if no time zone exists).
%% A literal "%" character.
|
class datetime |
|
DateTime(year, month=1, day=1, hour=0, minute=0, second=0.0)
Constructs a DateTime instance from the given values.
Assumes that the date is given in the Gregorian calendar
(which it the one used in many countries today).
WARNING: Only very limited error checking is done for this class.
The tuples are filled with the parameters from the last three numbers
in the current time tuple so only use the first six!!
Variable ranges:
MINYEAR 1
MAXYEAT 9999
year MINYEAR-MAXYEAR
month 1-12
day 1-31
hour 0-23
minute 0-59
second 0-59 Apparantly it is possible to have a double leap second in Python.
However, to maintain compatibility with databases, this isn't allowed.
WARNING: Seconds are rounded to two decimal places. |
|
Methods defined here:
- __cmp__(self, other)
- __eq__(self, other)
- __getitem__(self, item)
- Enable dictionary-style attribute reading for year, month, day, hour, minute and second.
- __init__(self, year, month, day, hour=0, minute=0, second=0, microsecond=0)
- Initialize datetime object.
All arguments are integers except second which can be a float.
WARNING: Possible problems with months with more days in than they actually have.
- __ne__(self, other)
- __repr__(self)
- Return a string representation of the object.
- __str__(self)
- Return the object as standard SQL.
- isoformat(self)
- Return the date and time as a standard SQL string of the format 'YYYY-MM-DD HH:MM:SS.ss'.
- now(self)
- Return the current date and time as a datetime.
- strftime(self, format)
- Format the time using standard time module string format strings.
%a Locale's abbreviated weekday name.
%A Locale's full weekday name.
%b Locale's abbreviated month name.
%B Locale's full month name.
%c Locale's appropriate date and time representation.
%d Day of the month as a decimal number [01, 31].
%H Hour (24-hour clock) as a decimal number [00, 23].
%I Hour (12-hour clock) as a decimal number [01, 12].
%j Day of the year as a decimal number [001, 366].
%m Month as a decimal number [01, 12].
%M Minute as a decimal number [00, 59].
%p Locale's equivalent of either AM or PM.
%S Second as a decimal number [00, 61]. (1)
%U Week number of the year (Sunday as the first day of the week)
as a decimal number [00, 53]. All days in a new year preceding
the first Sunday are considered to be in week 0.
%w Weekday as a decimal number [0(Sunday), 6].
%W Week number of the year (Monday as the first day of the week)
as a decimal number [00, 53]. All days in a new year preceding
the first Monday are considered to be in week 0.
%x Locale's appropriate date representation.
%X Locale's appropriate time representation.
%y Year without century as a decimal number [00, 99].
%Y Year with century as a decimal number.
%Z Time zone name (no characters if no time zone exists).
%% A literal "%" character.
- timetuple(self)
- Return the date and time as a python tuple as constructed by time.localtime().
WARNING: The last 3 entries in the tuple are obtained from time.localtime()
and do not represent anything.
|
class time(datetime) |
|
Construct an object holding a time value.
Is just another name binding for DateTime().
The date part is set to '2000-01-01'. |
|
Methods defined here:
- __init__(self, hour=0, minute=0, second=0, microsecond=0)
- __repr__(self)
- Return a string representation of the object.
- isoformat(self)
- Return the time as a standard SQL string in the format 'HH:MM::SS.ss'.
- now(self)
- Return the current date and time as a datetime.
- timetuple(self)
Methods inherited from datetime:
- __cmp__(self, other)
- __eq__(self, other)
- __getitem__(self, item)
- Enable dictionary-style attribute reading for year, month, day, hour, minute and second.
- __ne__(self, other)
- __str__(self)
- Return the object as standard SQL.
- strftime(self, format)
- Format the time using standard time module string format strings.
%a Locale's abbreviated weekday name.
%A Locale's full weekday name.
%b Locale's abbreviated month name.
%B Locale's full month name.
%c Locale's appropriate date and time representation.
%d Day of the month as a decimal number [01, 31].
%H Hour (24-hour clock) as a decimal number [00, 23].
%I Hour (12-hour clock) as a decimal number [01, 12].
%j Day of the year as a decimal number [001, 366].
%m Month as a decimal number [01, 12].
%M Minute as a decimal number [00, 59].
%p Locale's equivalent of either AM or PM.
%S Second as a decimal number [00, 61]. (1)
%U Week number of the year (Sunday as the first day of the week)
as a decimal number [00, 53]. All days in a new year preceding
the first Sunday are considered to be in week 0.
%w Weekday as a decimal number [0(Sunday), 6].
%W Week number of the year (Monday as the first day of the week)
as a decimal number [00, 53]. All days in a new year preceding
the first Monday are considered to be in week 0.
%x Locale's appropriate date representation.
%X Locale's appropriate time representation.
%y Year without century as a decimal number [00, 99].
%Y Year with century as a decimal number.
%Z Time zone name (no characters if no time zone exists).
%% A literal "%" character.
| |