[Zope3-dev] zc.datetimewidget+UTC exception

Gary Poster gary at zope.com
Mon Jul 17 13:55:02 EDT 2006


On Jul 17, 2006, at 12:53 PM, Adam Groszer wrote:

> Hi there,
>
> Anybody tried to use the above?
> For me it raises
>
>   Module zope.app.form.utility, line 348, in getWidgetsData
>   Module zope.app.form.browser.widget, line 295, in getInputValue
>   Module zc.datetimewidget.datetimewidget, line 123, in _toFieldValue
>     res = normalizeDateTime(res, self.request)
>   Module zc.datetimewidget.datetimewidget, line 48, in  
> normalizeDateTime
>     dt = zc.i18n.date.normalize(request, dt)
>   Module zc.i18n.date, line 74, in normalize
>     tzu = tzinfo.fromutc(dt).tzinfo
> ValueError: fromutc: dt.tzinfo is not self
>
> Seems like that happens when in zc.i18n.date tzinfo == UTC
>
> def normalize(request, dt):
>     if dt.tzinfo is None:
>         tzinfo = ITZInfo(request)
>     else:
>         tzinfo = dt.tzinfo
>
>     tzu = tzinfo.fromutc(dt).tzinfo
>
> Anyway normalizing an UTC datetime to UTC is useless?!?!?
> So if nobody goes against I'll correct that.

Hi Adam.  I'm trying to follow, and having a bit of a hard time,  
perhaps because I'm trying to work too quickly. :-)

I thought you meant that the following test of zc.i18n.date.normalize  
would fail:

     >>> dt = datetime.datetime(2006, 5, 1, 10, tzinfo=pytz.UTC)
     >>> normalize(request, dt)
     datetime.datetime(2006, 5, 1, 10, 0, tzinfo=<UTC>)

However, I actually added this test to zc.i18n.date and it passed.  I  
checked it in (revision 69155), but I assume that means that I still  
don't understand what the problem you identified is.  Could you maybe  
post a doctest that fails?

Thanks

Gary


More information about the Zope3-dev mailing list