[Zope3-dev] Can we remove ZopeLegacy for now?

Hannu Krosing hannu@krosing.net
16 Mar 2002 00:07:48 +0500


On Sat, 2002-03-16 at 00:13, Guido van Rossum wrote:
> I know that most of this discussion is irrelevant now that I've
> expressed enthusiasm about tzinfo objects, but I want to gripe a
> little bit.
> 
> > I've read the wiki pages and much of the discussion on python-dev,
> > and I'm actually not sure what the real issues are with timezone
> > support. I've seen the incredibly complex examples concerning adding
> > datetimes from different timezones across DST boundaries and
> > such.
> 
> The example in this page:
> 
>   http://www.zope.org/Members/fdrake/DateTimeWiki/NaiveTime
> 
> is far from complex.  It only involves one time in one timezone, and
> asks the question what should happen if we add a whole number of days
> across a DST jump.  Re-read the page before you reply, please.

As I already replied on that wiki, an elegant way to give the time delta
explicit precision - if we add one day whe just operate on days, if we
add 24 hours then we compute in UTC and convert back to whatever tz we
had. if we need 2days and3 hour later we do (D + 2days) + 3 hours.

Else there is no way to do some ops, like adding 1 month - there is no
one value for one month in days or hours or seconds, it _only_ makes
sense in *months*.

Doing it this way also quietly removes most problems of leap seconds and
and leap years (or rather pushes them into conversion routines from/to
Universal Seconds or whatever)

And I think that at least days-in-month should also take negative values
(like current array indexes), so that 

2002.02.-1 == 2002.02.29

2002.02.-1 + 1MO == 2002.03.-1 == 2002.03.31

2002.02.-1 + 2Y == 2004.02.-1 == 2004.02.29

> 
> Since datetime objects are immutable (this is an absolute requirement
> in the specs, coming from the Zope Pope), assigning a timezone has to
> be done by creating a new object anyway.  It might as well be a
> subclass instance then.

Or perhaps TZ should not be a subclass at all but rather a Viewer object
of DateTime object so that the same DateTime can be viewed in several
timezones

------------------------
Hannu