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 requestTZcomponent.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 alsodt = 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 UTCrequestTZ = 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 _______________________________________________ Zope3-dev mailing list [email protected] Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
