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
Post a Comment