richard
index
/home/ping/web/bc/date/richard.py

Date.py - by Richard Shiao
 
Represents dates on the Gregorian Calendar, containing fields for
four digit year, two digit month, and two digit day.  Includes
comparision, addition, and subtraction features.

 
Classes
            
Date
 
class Date
       
   Methods defined here:
__add__(self, inc)
Returns a date plus the amount given in inc.
Positive values for inc will cause the date returned to be
inc days after self.self.
Negative values for inc will cause the date returned to be
inc days before self.self.
__cmp__(self, other)
 If self occurrs before other Date, return -1.  If self occurrs later than
other, return 1.  If self is other Date, return 0.
__init__(self, year=1900, month=1, day=1)
Initializes date object with 1900-01-01, unless respective
arguments supplied.  Year must be a positive integer, and
must be explicit (e.g. 99 is not 1999).
Month must be an integer between 1 and 12.
Day must be a existing day, given the year and month.
__str__(self, format='text')
 Converts a Date object to a string in the format YYYY-MM-DD.  Or, if
'text' specified for the argument format, converts Date object to string
in format 'Month DD, YYYY'
__sub__(self, inc)
Returns a date minus the amount given in inc.
Positive values for inc will cause the date returned to be
inc days before self.self.
Negative values for inc will cause the date returned to be
inc days after self.self.
isLeapYear(self)
Returns 1 if self is part of leap year. Else, returns 0.
 
If a year is divisible by 4, and not divisible by 100, it is
a leap year.
If a year is divisible by 400, it is a leap year.
All other years are not leap years.
newDate(self, str)
Return a new Date object given a string formatted date: YYYY-MM-DD.
Year must be four digits long.  Month must be two digits long.mro
Day must be two digits long.
next(self)
Returns the date one day after self.self.
num_days(self, month)
Returns the number of days in a given month.
 
The argument month is an integer 1 - 12.
If the month is February, checks whether self is a leap year.
prev(self)
Returns the date one day before self.self.
set(self, year, month, day)
Sets self to have new values for year, month, and day.

Data and non-method functions defined here:
__doc__ = None
__module__ = 'richard'
month = {1: 'January', 2: 'February', 3: 'March', 4: 'April', 5: 'May', 6: 'June', 7: 'July', 8: 'August', 9: 'September', 10: 'October', ...}

 
Data
             __file__ = './richard.pyc'
__name__ = 'richard'