Am I asking too much from datetime?

thehaas at binary.net thehaas at binary.net
Tue Jun 1 13:26:07 CEST 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm trying to use the datetime module.  The following seems to work
any day except the first day of the month:

>>> import datetime
>>> today = datetime.date.today()
>>> print today
2004-06-01
>>> yesterday = datetime.date(today.year, today.month, today.day-1)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: day is out of range for month

In other languages (specifically Java, but I'm sure these are others),
this would come out as "2004-05-31".

Is this is a bug, or outside of the functionality of datetime?


- -- 
Mike Hostetler          
thehaas at binary.net 
http://www.binary.net/thehaas 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAvGe4aP33v4T41CURAkQGAKChO0yxPDxHwXHTsNOb0eO92zECGgCdHKZ2
Irj6f33KpdXvwxsIhkM+Bo8=
=IRWr
-----END PGP SIGNATURE-----



More information about the Python-list mailing list