[Zope] Strange date handling problems

Ty Sarna tsarna@endicor.com
Sun, 7 Feb 1999 13:16:04 -0600 (CST)


I'm getting unexpected results when doing computations on DateTime
instances. For example, the following should always result in 'd' being the
first of the previous month to 'date':

d = date - date.day()		#	1999/5/14 - 13 = 1999/4/30
d = d - (d.day() - 1)		#	1999/4/30 - (30 - 1) =
				#	1999/4/30 - 29 = 1999/4/1

Thie works great, unless 'date' is in May, in which case I end up with
1999/3/31 instead. A similar computation to find the first of the next
month also gives strange results if the start date is in March. In other
words, if the correct result is April Fool's, I get something else
instead!

Another, more involved set of calculations gives incorrect results for
most dates in October, but is fine for any other month. What's going on?