This repository was archived by the owner on Nov 22, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 44import sys
55import random
66import datetime
7+ import pytz
78import json
89
910sys .path .insert (0 , os .path .abspath ('.' ))
@@ -44,8 +45,12 @@ def test_find_zone(domain_name=None):
4445 print ('zone: %s %s' % (zone_id , zone_name ), file = sys .stderr )
4546
4647def rfc3339_iso8601_time (hour_delta = 0 , with_hms = False ):
47- # format time (with an hour offset in RFC3339 ISO8601 format (and do it UTC time)
48- dt = (datetime .datetime .now (datetime .UTC ).replace (microsecond = 0 ) + datetime .timedelta (hours = hour_delta ))
48+ # format time (with an hour offset in RFC3339 or ISO8601 format (and do it UTC time)
49+ if sys .version_info [:3 ][0 ] <= 3 and sys .version_info [:3 ][1 ] <= 10 :
50+ dt = datetime .datetime .utcnow ().replace (microsecond = 0 , tzinfo = pytz .UTC )
51+ else :
52+ dt = datetime .datetime .now (datetime .UTC ).replace (microsecond = 0 )
53+ dt += datetime .timedelta (hours = hour_delta )
4954 if with_hms :
5055 return dt .isoformat ().replace ('+00:00' , 'Z' )
5156 return dt .strftime ('%Y-%m-%d' )
Original file line number Diff line number Diff line change 55import json
66import random
77import datetime
8+ import pytz
89
910sys .path .insert (0 , os .path .abspath ('.' ))
1011sys .path .insert (0 , os .path .abspath ('..' ))
1516cf = None
1617
1718def rfc3339_iso8601_time (hour_delta = 0 , with_hms = False ):
18- # format time (with an hour offset in RFC3339 ISO8601 format (and do it UTC time)
19- dt = (datetime .datetime .now (datetime .UTC ).replace (microsecond = 0 ) + datetime .timedelta (hours = hour_delta ))
19+ # format time (with an hour offset in RFC3339 or ISO8601 format (and do it UTC time)
20+ if sys .version_info [:3 ][0 ] <= 3 and sys .version_info [:3 ][1 ] <= 10 :
21+ dt = datetime .datetime .utcnow ().replace (microsecond = 0 , tzinfo = pytz .UTC )
22+ else :
23+ dt = datetime .datetime .now (datetime .UTC ).replace (microsecond = 0 )
24+ dt += datetime .timedelta (hours = hour_delta )
2025 if with_hms :
2126 return dt .isoformat ().replace ('+00:00' , 'Z' )
2227 return dt .strftime ('%Y-%m-%d' )
You can’t perform that action at this time.
0 commit comments