Date

A date may be any date (including forever into the past and forever into the future).

A date is assumed to be immutable - multiple entities may safely refer to the same date. For this reason, there are no "set" methods.

Public data members:

time

Internal representation of the date - seconds since the beginning of the epoch. Don't modify this.

This attribute used to contain the internal representation, but now it is a pseudo-attribute: it is computed upon demand.

This class includes a number of class variables for symbolic constants: sunday, monday, tuesday, wednesday, thursday, friday, saturday, january, february, march, april, may, june, july, august, september, october, november, december.

Methods

__add__(self, days)

   def __add__(self, days):

Returns a new date consisting of the given date plus days.

__cmp__(self, other)

   def __cmp__(self, other):

Allows us to use the comparison operators on dates.

__currentDate(self)

   def __currentDate(self):

returns the current date, which is the current time truncated of all precision greater than the day.

__getattr__(self, attr)

   def __getattr__(self, attr):

Provides the transparent computation of the time attribute.

__init__(self, time, stdfmt, other, year, month, day, foreverPast, foreverFuture, now)

   def __init__(self, time = 0, stdfmt = "", other = None, year = 0, 
                month = 0, day = 0, foreverPast = 0, foreverFuture = 0, 
                now = 0
                ):

__setstate__(self, dict)

   def __setstate__(self, dict):

Allows conversion from old-style representation.

__str__(self)

   def __str__(self):

Returns the date formatted in the new standard format.

__sub__(self, other)

   def __sub__(self, other):

Returns the difference (in days) between two dates. A day is assumed to be 86400 seconds.

If other is not a date, but is a number, a new date is returned that is other days before self.

__timeToDate(self, t)

   def __timeToDate(self, t):

Returns a year/month/day tuple for the localtime represented by t.

_toTime(self)

   def _toTime(self):

Returns the localtime representation of the date.

dst(self)

   def dst(self):

Returns true if daylight savings time is in effect for this date, false if not.

format(self, formatStr)

   def format(self, formatStr):

Returns the date and time formated using the strftime function.

formatNewStd(self)

   def formatNewStd(self):

Returns a string consisting of the receiver formatted as mm/dd/yyyy

formatShort(self)

   def formatShort(self):

Returns a string consisting of the receiver formatted as mmddyy

formatStd(self)

   def formatStd(self):

Returns a string consisting of the receiver formatted as mm/dd/yy

getDay(self)

   def getDay(self):

Returns the day of the month.

getDayOfWeek(self)

   def getDayOfWeek(self):

Returns the current day of the week as a number.

getMonth(self)

   def getMonth(self):

Returns the month

getYear(self)

   def getYear(self):

Returns the year.

last(self, weekday)

   def last(self, weekday):

Returns a new date which is the given weekday immediately prior to the date of self. If selfs date falls on that weekday, returns a copy of self.

next(self, weekday)

   def next(self, weekday):

Returns a new date which is the given weekday following the date of self. If selfs date falls on that weekday, returns a copy of self.

ymd(self)

   def ymd(self):

Returns a tuple consisting of the year, month, and day.