Re: [Zope] Re: Help with DateTime.earliestTime()

2007-08-27 Thread Eric Thomas
On 8/27/07, Dieter Maurer [EMAIL PROTECTED] wrote:

 Andreas Jung wrote at 2007-8-26 21:23 +0200:
  ...
 If you can: use Python's datetime module. DateTime is broken in many
 ways.

 If it handles daytime saving and addition by some float days -- it will
 not have any chance...

 If it does not handle daytime saving -- then it misses an essential
 use case...

 Some problems come from the complexity of the real world and
 not from a particular implementation



 --
 Dieter


In this case it seems that the complexity is being added by the DateTime
implementation.  When given an int number of days and a DateTime that has no
time element, DateTime should not convert everything down to seconds and
account for DST that happens to occur during the period.

When adding days + days, I'd expect to get a result that only considers
days; not DST.
So I agree with your earlier post that DateTime should treat int and float
addition differently.  It should also probably look at the DateTime and
revert to integer math if there is no time element present.

- Eric
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Help with DateTime.earliestTime()

2007-08-25 Thread Eric Thomas
I've been having a site problem that I've tracked down to DateTime.  Simply
enough, the code snippets below both try to add 31 days to the first day in
October.  I'm expecting this to result in the first day of November.

Good Example:

 from DateTime import DateTime
 start=DateTime('2005/10/01 01:00:00 GMT-5')
 print start
2005/10/01 01:00:00 GMT-5
 earlyStart=start.earliestTime()
 print earlyStart
2005/10/01
 print earlyStart+31
2005/11/01

Bad Example:  (Here's the problem)

 from DateTime import DateTime
 start=DateTime('2005/10/01 01:00:00 US/Central')
 print start
2005/10/01 01:00:00 US/Central
 earlyStart=start.earliestTime()
 print earlyStart
2005/10/01
 print earlyStart+31
2005/10/31 23:00:00 US/Central

I've confirmed this occurs with several of the US/ timezones (US/Pacific,
US/Alaska, etc)

Can anyone help me figure out why the resulting date is coming up 1 hour
short of the expected 2005/11/01 ?

Thanks!

Eric
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )