python - How to use abbreviated timezone name(PST, IST) in Pytz -


i need know way of using abbreviated timezone name pst, ist etc on pytz.

now can able convert between timezone using timezone name "america/los_angeles".

instead need find way of using timezone name pst, ist etc.,

sample code have used conversion.

def local2utc(self, dt):      from_zone = tz.gettz('america/los_angeles')     to_zone = tz.gettz('utc')     local = dt.replace(tzinfo=from_zone)     print("converted time")     print(local.astimezone(to_zone).replace(tzinfo = none))     return local.astimezone(to_zone).replace(tzinfo = none) 

someone let me know way of achieving same.

this nature impossible, because abbreviations can mean multiple (different) time zones:

http://www.timeanddate.com/time/zones/

if want work timezones, make dictionary mapping abbreviation long name.


Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -