Bugs item #1553577, was opened at 2006-09-06 11:11
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1553577&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Skip Montanaro (montanaro)
>Assigned to: Tim Peters (tim_one)
Summary: datetime.datetime.now() mangles tzinfo

Initial Comment:
When using the pytz package (http://pytz.sf.net/) to create
timezone info objects datetime.datetime.now() behaves
differently than the regular datetime.datetime()
contstructor.  Here's an example:

    >>> import pytz
    >>> info = pytz.timezone("US/Central")
    >>> info
    <DstTzInfo 'US/Central' CST-1 day, 18:00:00 STD>
    >>> import datetime
    >>> now = datetime.datetime.now(tz=info)
    >>> now
    datetime.datetime(2006, 9, 6, 12, 44, 18, 983849,
tzinfo=<DstTzInfo 'US/Central' CDT-1 day, 19:00:00 DST>)
    >>> t2 = datetime.datetime(2006, 9, 6, 12, 44, 18,
983849, tzinfo=info)
    >>> t2
    datetime.datetime(2006, 9, 6, 12, 44, 18, 983849,
tzinfo=<DstTzInfo 'US/Central' CST-1 day, 18:00:00 STD>)
    >>> now.tzinfo == info
    False
    >>> t2.tzinfo == info
    True

It appears that datetime.datetime.now() makes an
off-by-one-hour copy of the timezone info it was passed.
I've reproduced this on 2.4.3 and 2.5c1 as of August 17.

(It's also a little annoying that the timezone arg for
datetime.datetime.now() is "tz" while the timezone arg for
datetime.datetime() is "tzinfo".  Is there a good
reason for
them to be different?)

Skip


----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2006-09-07 00:08

Message:
Logged In: YES 
user_id=33168

Since Tim wrote this code AFAIK, there *had* to be a good
reason. :-)

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1553577&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to