python - Why does creating a datetime with a tzinfo from pytz show a weird time offset? -


can explain me why not same result in those?

import datetime,pytz var1 = datetime.datetime(2017,10,25,20,10,50,tzinfo=pytz.timezone("europe/athens"))) print(var1) 

the output of code is: 2017-10-25 20:10:50+01:35

import datetime,pytz var1 = datetime.datetime(2017,10,25,20,10,50) var1 = pytz.timezone("europe/athens").localize(var1) print(var1) 

the output of code is: 2017-10-25 20:10:50+03:00

my question why have different timezones (1:35 , 3:00). know second code true because utc 3:00. can tell me why getting 1:35 in first one?

there no problem, datetime happily reports offset of tzinfo in whatever reference frame.

by default pytz.timezone doesn't give utc offset lmt (local mean time) offset:

>>> pytz.timezone("europe/athens") <dsttzinfo 'europe/athens' lmt+1:35:00 std> #                          ^^^-------------------- local mean time 

however when localize it:

>>> var1 = datetime.datetime(2017,10,25,20,10,50) >>> var1 = pytz.timezone("europe/athens").localize(var1) >>> var1.tzinfo <dsttzinfo 'europe/athens' eest+3:00:00 dst> #                          ^^^^-------------------- eastern european summer time 

a different offset reported, time based on eest.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -