python - Set tz to datetime instance having only tzname value ("EDT", "CDT", ...) -


this question has answer here:

i've got tz names in format: "edt", "cdt".

is possible set timezone datetime instance such tz names?

on many unix systems (including *bsd, linux, solaris, , darwin), more convenient use system’s zoneinfo (tzfile(5)) database specify timezone rules. this, set tz environment variable path of required timezone datafile, relative root of systems ‘zoneinfo’ timezone database, located @ /usr/share/zoneinfo. example, 'us/eastern', 'australia/melbourne', 'egypt' or 'europe/amsterdam'.

>>> os.environ['tz'] = 'us/eastern' >>> time.tzset() >>> time.tzname ('est', 'edt') >>> os.environ['tz'] = 'egypt' >>> time.tzset() >>> time.tzname ('eet', 'eest') 

it work fine valid timezone strings too


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -