[Zope3-dev] mini-RFC: times and timezones
Gary Poster
gary at zope.com
Sun Feb 27 06:19:47 EST 2005
On Feb 27, 2005, at 5:52 AM, Stephan Richter wrote:
> On Saturday 26 February 2005 18:23, Gary Poster wrote:
>>>> * Views should generally display dates (stored with a UTC
>>>> timezone)
>>>> using something like this:
>>>> formatter = request.locale.dates.getFormatter('dateTime',
>>>> length='short')
>>>> tz = zope.interface.common.tzinfo.ITZInfo(request)
>>>> return formatter.format(zope.i18n.switchTimeZones(date, tz)
>>>
>>> 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:
>>
>> from zope.interface.common.tzinfo import ITZInfo
>> formatter = request.locale.dates.getFormatter('dateTime',
>> length='short')
>
> Have you read my book? :-)
:-) Only a few chapters so far, but I have a ZC-purchased hard copy in
my backpack.
> I have outlined a TALES formatting namespace there:
>
> <div tal:content="context/zope:modified/format:fullDateTime">
>
> (http://dev.zope.org/Zope3/Zope3Book/talesns.html)
Cool! That looks like a good way to go.
I wish the request were easily available so we could adapt it to
ITZInfo in the format:fullDateTime code (or even the zope:modified
code). The only solution I like enough is to iterate over the
participants of the current interaction to find an IRequest, and assume
that's the right one. That's not ideal, but it would work, and even be
right for all of the cases I know about.
Gary
More information about the Zope3-dev
mailing list