1.3.1 Module-Level Functionality

The datetime module exports the following constants:

MINYEAR
The smallest year number allowed in a date or datetime object. MINYEAR is 1.

MAXYEAR
The largest year number allowed in a date or datetime object. MAXYEAR is 9999.

The datetime module exports the following functions:

now( )
Returns a datetime.datetime object representing the current date and time

isodatetime2tuple( sql)
Returns the date and time as a python tuple as constructed by time.localtime(). sql is the ISO representation of the datetime as used in SQL strings.

Warning: The last 3 entries in the tuple are obtained from time.localtime() and do not represent anything.

isotime2tuple( sql)
Returns the time as a python tuple as constructed by time.localtime().

Warning: The first 3 and last 3 entries in the tuple are obtained from time.localtime() and do not represent anything.

isodate2tuple( sql)
Returns the date as a python tuple as constructed by time.localtime(). sql is the ISO representation of the datetime as used in SQL strings.

Warning: The last 6 entries in the tuple are obtained from time.localtime() and do not represent anything.

For Example:

>>> import web # Necessary to set up the paths so datetime can be imported
>>> import datetime
>>> datetime.MINYEAR
1
>>> datetime.MAXYEAR
9999
>>> datetime.now()
datetime.datetime(2004,5,3,17,36,18)
>>> datetime.isotime2tuple('17:40:20')
(0, 0, 0, 17, 40, 20, 0, 0, -1)
See About this document... for information on suggesting changes.