[Zope3-dev] zc.datetimewidget+UTC exception

Gary Poster gary at zope.com
Mon Jul 17 14:09:57 EDT 2006


On Jul 17, 2006, at 1:59 PM, Adam Groszer wrote:

> Hello Gary,
>
> Sorry for the confusion, just managed it, the last one should fail.
>
>     """this method normalizes datetime instances by converting them to
>     utc, daylight saving times are also taken into account. This
>     method requires an adapter to get the tzinfo from the request.
>
>>>> from zope import component, interface
>>>> import pytz
>>>> requestTZ = pytz.timezone('Europe/Vienna')
>>>> from zope.interface.common.idatetime import ITZInfo
>>>> from zope.publisher.interfaces.browser import IBrowserRequest
>>>> from zope.publisher.browser import TestRequest
>>>> @interface.implementer(ITZInfo)
>     ... @component.adapter(IBrowserRequest)
>     ... def tzinfo(request):
>     ...     return requestTZ
>>>> component.provideAdapter(tzinfo)
>>>> dt = datetime.datetime(2006,5,1,12)
>>>> request = TestRequest()
>
>     The Vienna timezone has a 2 hour offset to utc at this date.
>>>> normalize(request,dt)
>     datetime.datetime(2006, 5, 1, 10, 0, tzinfo=<UTC>)
>
>     At this date the timezone has only a one hour offset.
>>>> dt = datetime.datetime(2006,2,1,12)
>>>> normalize(request,dt)
>     datetime.datetime(2006, 2, 1, 11, 0, tzinfo=<UTC>)
>
>     Normalizing UTC to UTC should work also
>>>> dt = datetime.datetime(2006,5,1,12,tzinfo=pytz.UTC)
>>>> normalize(request,dt)
>     datetime.datetime(2006, 5, 1, 12, 0, tzinfo=<UTC>)
>
>     This way too UTC to UTC
>>>> requestTZ = pytz.UTC
>>>> dt = datetime.datetime(2006,5,1,12)
>>>> normalize(request,dt)
>     datetime.datetime(2006, 5, 1, 12, 0, tzinfo=<UTC>)
>     """

Ah, I see (and I was able to duplicate).  Yup, that's a bug.  Please  
do fix it.

Thanks!

Gary


More information about the Zope3-dev mailing list