diff options
-rwxr-xr-x | daemons/dnssec/ipa-ods-exporter | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/daemons/dnssec/ipa-ods-exporter b/daemons/dnssec/ipa-ods-exporter index 03dcfbc83..4c6649c2f 100755 --- a/daemons/dnssec/ipa-ods-exporter +++ b/daemons/dnssec/ipa-ods-exporter @@ -17,6 +17,7 @@ Purpose of this replacement is to upload keys generated by OpenDNSSEC to LDAP. from binascii import hexlify from datetime import datetime +import dateutil.tz import dns.dnssec import fcntl import logging @@ -80,7 +81,12 @@ def datetime2ldap(dt): return dt.strftime(ipalib.constants.LDAP_GENERALIZED_TIME_FORMAT) def sql2datetime(sql_time): - return datetime.strptime(sql_time, "%Y-%m-%d %H:%M:%S") + """Convert SQL date format from local time zone into UTC.""" + localtz = dateutil.tz.tzlocal() + localtime = datetime.strptime(sql_time, "%Y-%m-%d %H:%M:%S").replace( + tzinfo=localtz) + utctz = dateutil.tz.gettz('UTC') + return localtime.astimezone(utctz) def sql2datetimes(row): row2key_map = {'generate': 'idnsSecKeyCreated', |