mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Return offset in the same format as Unix
This commit is contained in:
parent
5656183c5e
commit
73e033f555
1 changed files with 3 additions and 4 deletions
|
@ -226,11 +226,10 @@ def get_offset():
|
|||
'''
|
||||
# http://craigglennie.com/programming/python/2013/07/21/working-with-timezones-using-Python-and-pytz-localize-vs-normalize/
|
||||
tz_object = pytz.timezone(get_zone())
|
||||
utc_time = pytz.utc.localize(datetime.today())
|
||||
utc_time = pytz.utc.localize(datetime.utcnow())
|
||||
loc_time = utc_time.astimezone(tz_object)
|
||||
norm_time = tz_object.normalize(loc_time)
|
||||
time_zone = norm_time.astimezone(tz_object)
|
||||
return time_zone.utcoffset().total_seconds() / 3600
|
||||
return norm_time.strftime('%z')
|
||||
|
||||
|
||||
def get_zonecode():
|
||||
|
@ -247,7 +246,7 @@ def get_zonecode():
|
|||
salt '*' timezone.get_zonecode
|
||||
'''
|
||||
tz_object = pytz.timezone(get_zone())
|
||||
loc_time = tz_object.localize(datetime.today())
|
||||
loc_time = tz_object.localize(datetime.utcnow())
|
||||
return loc_time.tzname()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue