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
    ... @component.adapter(IBrowserRequest)
    ... def tzinfo(request):
    ...     return requestTZ
dt = datetime.datetime(2006,5,1,12)
request = TestRequest()

    The Vienna timezone has a 2 hour offset to utc at this date.
    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)
    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)
    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)
    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.


Zope3-dev mailing list
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to