spug.util.Date
index
/home/mmuller/w/spug/util/Date.py

Simple Date class.
 
Synopsis:
 
{{
   # get the current date
   d = Date()
   d = Date(now = 1)
   
   # get 2/12/1999
   d = Date(year = 1999, month = 2, day = 12)
   
   # get 2/12/1999 from a string
   d = Date(stdfmt = '2/12/99')
   d = Date(stdfmt = '2/12/1999')
   
   # get a date from the current timeval
   d = Date(time = time.time())
   
   # get a date infinitely far in the future or past
   d = Date(foreverPast = 1)
   d = Date(foreverFuture = 1)
}}

 
Modules
       
time
re
string
time

 
Classes
       
exceptions.Exception(exceptions.BaseException)
util.Date.DateParseError
util.Date.Date

 
class 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 defined here:
__add__(self, days)
Returns a new date consisting of the given date plus /days/.
__cmp__(self, other)
Allows us to use the comparison operators on dates.
__getattr__(self, attr)
Provides the transparent computation of the time attribute.
__init__(self, time=0, stdfmt='', other=None, year=0, month=0, day=0, foreverPast=0, foreverFuture=0, now=0)
__setstate__(self, dict)
Allows conversion from old-style representation.
__str__(self)
Returns the date formatted in the new standard format.
__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/.
dst(self)
Returns true if daylight savings time is in effect for this date,
false if not.
format(self, formatStr)
Returns the date and time formated using the strftime function.
formatNewStd(self)
Returns a string consisting of the receiver formatted as `mm/dd/yyyy`
formatShort(self)
Returns a string consisting of the receiver formatted as mmddyy
formatStd(self)
Returns a string consisting of the receiver formatted as `mm/dd/yy`
getDay(self)
Returns the day of the month.
getDayOfWeek(self)
Returns the current day of the week as a number.
getMonth(self)
Returns the month
getYear(self)
Returns the year.
last(self, weekday)
Returns a new date which is the given /weekday/ immediately prior to
the date of /self/.  If /self/s date falls on that weekday, returns
a copy of /self/.
next(self, weekday)
Returns a new date which is the given /weekday/ following the date of 
/self/.  If /self/s date falls on that weekday, returns a copy of /self/.
ymd(self)
Returns a tuple consisting of the year, month, and day.

Data and other attributes defined here:
april = 4
august = 8
december = 12
february = 2
friday = 5
january = 1
july = 7
june = 6
march = 3
may = 5
monday = 1
november = 11
october = 10
saturday = 6
september = 9
sunday = 0
thursday = 4
tuesday = 2
wednesday = 3

 
class DateParseError(exceptions.Exception)
    Exception thrown when date is of bad format
 
 
Method resolution order:
DateParseError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x8140ce0>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
Data
        MAXFLOAT = 1.7976000000000001e+308
MINFLOAT = -1.7976000000000001e+308