[issue22994] datetime buggy

santhosh report at bugs.python.org
Fri Dec 5 11:39:38 CET 2014


santhosh added the comment:

Thanks simeon.visser,
I understood your point. Didn't got your point earlier.

Hey belopolsky,
Here is the solution
val=datetime.datetime.strptime("2015-02-01",'%Y-%m-%d').date()
zon=pytz.timezone('US/Pacific')

Bad Code:
dt=datetime.datetime(val.year,val.month,val.day, tzinfo=zon)
Good Code:
dt=zon.localize(datetime.datetime(val.year,val.month,val.day))

In Linux, good code works perfectly

Both code are working perfectly in Mac

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22994>
_______________________________________


More information about the Python-bugs-list mailing list