On 10/5/07, Laurence Rowe <[EMAIL PROTECTED]> wrote:
> It seems though that the new timezones are not used much... doing a
> DateTime() gives me DateTime('2007/10/05 14:20:27.204176 GMT+1') (with
> my pathc applied too). Looking up tz = d._tzinfo[d.timezone()] gives me
> an old style timezone, as _tz is 'GMT+1'.

If a the timezone has a name that pytz understands then it uses pytz.
Otherwise it falls back on DateTime's timezone database. The most
common example of when pytz won't be used is with fixed offset
timezones like GMT+1. pytz.common_timezones doesn't doesn't contain
time zones like this. Anyway DateTime handles fixed offset time zones
just fine since there's no daylight savings to deal with.

> It would be very useful to be able to get pytz tzinfo for a DateTime
> object. It would allow me to return a timezone aware datetime.datetime
> from asdatetime().

DateTime instances only store the name of their timezone, not the
timezone object. So when converting to a datetime object I suggest
that you generate a tzinfo object yourself. This shouldn't be too hard
since DateTime is willing to give you a timezone that provides a name,
dst flag, and offset from UTC. See _timezone.info()

> Ideally the old names should be mapped onto pytz timezones.

Names that pytz understands use pytz time zone info, regardless of
when the DateTime instance was created. Or maybe you are asking
something else.

Also DateTime supports some abbreviations. For example, 'est' is
mapped to 'US/Eastern'. So old instances that use 'est' as a time zone
should work with pytz. There are probably improvements that can be
made here, but I didn't bother since my goal was to change as little
as possible.

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

Reply via email to