Date type

Gerrit Holl gerrit at nl.linux.org
Fri May 16 11:31:46 EDT 2003


Batista, Facundo schreef op vrijdag 16 mei om 16:43:59 +0000:
> > a = Date()
> > a.month = 5
> > a.day = 15
> >
> > b = Date()
> > a.month = 5
> > b.day = 17
> >
> > print b-a
> 2
> > print a+1

> There is something like this already?

Python 2.3 has an excellent DateTime module:

  0 >>> import datetime
  1 >>> datetime.datetime(2003, 5, 19, 9, 00) - datetime.datetime.now()
datetime.timedelta(2, 56245, 430670)
  4 >>> datetime.datetime(2004, 2, 29)
datetime.datetime(2004, 2, 29, 0, 0)
  5 >>> datetime.datetime(2004, 2, 30)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: day is out of range for month

regards,
Gerrit.

-- 
60. If any one give over a field to a gardener, for him to plant it as
a garden, if he work at it, and care for it for four years, in the fifth
year the owner and the gardener shall divide it, the owner taking his part
in charge. 
        -- Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
	http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
	http://www.sp.nl/





More information about the Python-list mailing list