libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [libcloud] 02/02: Update header string in the BIND zone export content so it utilizes UTC instead of a local timestamp.
Date Sun, 11 Oct 2020 16:04:59 GMT
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit d5e957a1de40c216525fd0996ce04d74f3887886
Author: Tomaz Muraus <tomaz@tomaz.me>
AuthorDate: Sun Oct 11 15:35:53 2020 +0200

    Update header string in the BIND zone export content so it utilizes UTC
    instead of a local timestamp.
---
 libcloud/dns/base.py           | 4 ++--
 libcloud/test/dns/test_base.py | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libcloud/dns/base.py b/libcloud/dns/base.py
index a90f2e9..f6dad56 100644
--- a/libcloud/dns/base.py
+++ b/libcloud/dns/base.py
@@ -493,10 +493,10 @@ class DNSDriver(BaseDriver):
         records = zone.list_records()
         records = sorted(records, key=Record._get_numeric_id)
 
-        date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
+        date = datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
         values = {'version': __version__, 'date': date}
 
-        lines.append('; Generated by Libcloud v%(version)s on %(date)s' %
+        lines.append('; Generated by Libcloud v%(version)s on %(date)s UTC' %
                      values)
         lines.append('$ORIGIN %(domain)s.' % {'domain': zone.domain})
         lines.append('$TTL %(domain_ttl)s\n' % {'domain_ttl': zone.ttl})
diff --git a/libcloud/test/dns/test_base.py b/libcloud/test/dns/test_base.py
index 1ceba05..bb699f4 100644
--- a/libcloud/test/dns/test_base.py
+++ b/libcloud/test/dns/test_base.py
@@ -93,13 +93,13 @@ class BaseTestCase(unittest.TestCase):
         lines1 = result.split('\n')
         lines2 = content.split('\n')
 
-        now = datetime.datetime.now()
+        now = datetime.datetime.utcnow()
         date_str = "%s-%s-%s %s:%s:%s" % (now.year, zero_pad(now.month),
                                           zero_pad(now.day),
                                           zero_pad(now.hour),
                                           zero_pad(now.minute),
                                           zero_pad(now.second))
-        expected_header = "; Generated by Libcloud v%s on %s" % (__version__, date_str)
+        expected_header = "; Generated by Libcloud v%s on %s UTC" % (__version__, date_str)
 
         self.assertEqual(lines1[0], expected_header)
         self.assertEqual(lines2[0], expected_header)


Mime
View raw message