Fwd: [Zope-dev] Options replacing DateTime with datetime!?

Gustavo Niemeyer gustavo at niemeyer.net
Tue Sep 18 08:54:53 EDT 2007


Hey again Lennart,


> OK, I'm just going after my old notes here, and they could be wrong.
> It could be that these types of timezones doesn't work in a datetime string?

Maybe.   If there's a problem with parsing, I'll be happy to fix that.


> The important part is that there is some sort of way to tell the
> module what the local timezone is, so that you can test conversions.

Just use the POSIX-defined TZ variable, and the gettz() method
to retrieve the timezone.

   >>> from dateutil.tz import gettz

   >>> os.environ["TZ"] = "Brazil/East"
   >>> gettz()
   tzfile('/usr/share/zoneinfo/Brazil/East')

   >>> os.environ["TZ"] = "US/Eastern"
   >>> gettz()
   tzfile('/usr/share/zoneinfo/US/Eastern')


(...)
> But it makes it impossible without actually modifying the modules code
> somehow, and in my book, it is reasonable to call that impossible.

Just use gettz(), as explained above.  You'll get a richer source
of information for free.


> Of course nothing is impossible in computing.
(...)
> If I monkey-patch the module for testing, then am I really testing
> what goes on in production?

These are interesting statements.  I won't move into discussing them
because it won't benefit the main point.  If you'd enjoy some general
conceptual discussion we can do so privately.

-- 
Gustavo Niemeyer
http://niemeyer.net


More information about the Zope-Dev mailing list