Package lemon :: Package db :: Module date :: Class DateTime
[show private | hide private]
[frames | no frames]

Class DateTime

Known Subclasses:
Date, Time

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:
        year    1000-9999
        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.

Method Summary
  __init__(self, year, month, day, hour, minute, second, obj, ticks, sql, list)
Either set one of the sets options: obj - Database module DateTime class ticks - An object time.time() year, month, day, hour, minute, second - Each integers except second which can be a float.
  __cmp__(self, other)
  __getitem__(self, item)
Enable dictionary-style attribute reading for year, month, day, hour, minute and second.
  __str__(self)
Return the object as standard SQL.
  asSQL(self)
Return the date and time as a standard SQL string of the format 'YYYY-MM-DD HH:MM::SS.ss'.
  asSQLDate(self)
Return the date as a standard SQL string of the format 'YYYY-MM-DD'.
  asSQLDateTime(self)
Return the date and time as a standard SQL string of the format 'YYYY-MM-DD HH:MM::SS.ss'.
  asSQLTime(self)
Return the time as a standard SQL string in the format 'HH:MM::SS.ss'.
  asSQLTimestamp(self)
Return the date and time as a standard SQL timestamp string of the format 'YYYYMMDDHHMMSS'.
  list(self)
  tuple(self)
Returns the date and time as a python tuple as constructed by time.localtime().

Method Details

__init__(self, year=None, month=None, day=None, hour=None, minute=None, second=None, obj=None, ticks=None, sql=None, list=None)
(Constructor)

Either set one of the sets options:
obj                                 - Database module DateTime class
ticks                               - An object time.time()
year, month, day, hour, minute, second    - Each integers except second which can be a float.

__getitem__(self, item)
(Indexing operator)

Enable dictionary-style attribute reading for year, month, day, hour, minute and second.

__str__(self)
(Informal representation operator)

Return the object as standard SQL.

asSQL(self)

Return the date and time as a standard SQL string of the format 'YYYY-MM-DD HH:MM::SS.ss'.

asSQLDate(self)

Return the date as a standard SQL string of the format 'YYYY-MM-DD'.

asSQLDateTime(self)

Return the date and time as a standard SQL string of the format 'YYYY-MM-DD HH:MM::SS.ss'.

asSQLTime(self)

Return the time as a standard SQL string in the format 'HH:MM::SS.ss'.

asSQLTimestamp(self)

Return the date and time as a standard SQL timestamp string of the format 'YYYYMMDDHHMMSS'.

tuple(self)

Returns 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.

Generated by Epydoc 2.0 on Mon Nov 10 15:07:55 2003 http://epydoc.sf.net