[Zope3-dev] mini-RFC: times and timezones

Marius Gedminas mgedmin at b4net.lt
Sat Feb 26 19:32:46 EST 2005


On Sat, Feb 26, 2005 at 06:23:50PM -0500, Gary Poster wrote:
> On Feb 25, 2005, at 8:18 PM, Marius Gedminas wrote:
> >This looks like a mouthful.  Can we invent an obvious way to display
> >dates and times without having to remember weird three-line
> >incantations?  (Can anyone remember how to open a text file in Java
> >without looking it up?)
> 
> A good point.  Before talking about it more, for what it's worth, 
> here's the current revision of the three lines:
...
> The ITZInfo adaptation doesn't seem too onerous to me within the 
> context of using the locale formatter.  Marius, if you would like the 
> whole thing shorter (very reasonable), maybe we could register an 
> adapter for (datetime, request) (IView is deprecated so not sure what 
> we'd provide...) that did the right thing.  Maybe named views for the 
> four formatter length values would work.

Path adapters for page templates could also come in handy.

> So everyone is clear, hear are some more examples, if Stuart accepts 
> the patch or something similar to it.
> 
> Current call to get a now that will be stored:
> 
> dt = datetime.datetime.utcnow()
> 
> After change:
> 
> from pytz import utc
> dt = datetime.datetime.now(utc)
> 
> The call to convert timezone-aware datetimes from a user to utc will be 
> this:
> 
> from pytz import utc
> aware.astimezone(utc)

Cool!

Marius Gedminas
-- 
If the facts don't fit the theory, change the facts.
                -- Albert Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope3-dev/attachments/20050227/7dfc60d4/attachment.bin


More information about the Zope3-dev mailing list