datetime - What's wrong with this python timezone conversion? -


i want convert datetime us/eastern timezone budapest/europe timezone way:

import pytz datetime import datetime  et = pytz.timezone('us/eastern') cet = pytz.timezone('europe/budapest')  time = datetime(2013, 04, 18, 0, 0, tzinfo=et) newtime = time.astimezone(cet) 

this results newtime being: datetime.datetime(2013, 4, 18, 7, 0, tzinfo=<dsttzinfo 'europe/budapest' cest+2:00:00 dst>), should 2013,04,18,6,0 according time.is , timeanddate.com converters. do wrong ?

this because of daylight saving time issue. time passed datetime in et, not edt, hence result.

take @ pytz documentation, preferred way use localize method, rather passing tzinfo. you'll expected result if amend code use following line:

time = et.localize(datetime(2013, 04, 18, 0, 0)) 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -