i'm trying to convert whatever the user select time timezone it should convert into uk timezone. I've found a package in python called "pytz" but the list of timezones are different from my windows local system timezones. I've searched for micorsoft default system timezones and trying to convert them in uk timezones
please click the below link for microsoft default system timezone details.
for example instead passing 'Asia/Kolkata' to my "get_uk_time" function i'm trying to pass windows local system timezone as "Chennai, Kolkata, Mumbai, New Delhi" or India Standard Time or IN. similar way for other timezones which are available in the microsoft link above
i've tried below approch but unable to find how to convert above local windows system timezones.
from datetime import datetime
from pytz import timezone
def get_uk_time(time_zone):
try:
country_tz = timezone(time_zone)
format = "%Y, %m, %d, %H, %M, %S"
time_now = datetime.now(timezone(time_zone))
format_time = time_now.strftime(format)
london_tz = timezone('Europe/London')
local_time = country_tz.localize(datetime.strptime(format_time, format))
convert_to_london_time = local_time.astimezone(london_tz)
uk_time = convert_to_london_time.strftime('%H:%M')
return uk_time
except:
print('unable to find the timezone')
my_json = {'timezone': 'Asia/Kolkata'}
time_zone = my_json['timezone']
time_in_london = get_uk_time(time_zone)
print(time_in_london)
please help.