Skip to content

Commit

Permalink
Merge pull request ckan#9 from qld-gov-au/datetimeFix
Browse files Browse the repository at this point in the history
Use utc timezone so storage and helper functions work correctly
  • Loading branch information
duttonw authored Jul 30, 2020
2 parents 3dabb80 + cee8974 commit 8e10af6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ckanext/qa/bin/migrate_task_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

START_OF_TIME = datetime.datetime(1980, 1, 1)
END_OF_TIME = datetime.datetime(9999, 12, 31)
TODAY = datetime.datetime.now()
TODAY = datetime.datetime.utcnow()

# NB put no CKAN imports here, or logging breaks

Expand Down
5 changes: 2 additions & 3 deletions ckanext/qa/bin/running_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@
import copy
import datetime


class StatsCount(dict):
# {category:count}
_init_value = 0
report_value_limit = 150

def __init__(self, *args, **kwargs):
self._start_time = datetime.datetime.now()
self._start_time = datetime.datetime.utcnow()
super(StatsCount, self).__init__(*args, **kwargs)

def _init_category(self, category):
Expand Down Expand Up @@ -80,7 +79,7 @@ def report(self, indent=1, order_by_title=False, show_time_taken=True):
lines = [indent_str + 'None']

if show_time_taken:
time_taken = datetime.datetime.now() - self._start_time
time_taken = datetime.datetime.utcnow() - self._start_time
lines.append(indent_str + 'Time taken (h:m:s): %s' % time_taken)
return '\n'.join(lines)

Expand Down
4 changes: 2 additions & 2 deletions ckanext/qa/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class QA(Base):
openness_score_reason = Column(types.UnicodeText)
format = Column(types.UnicodeText)

created = Column(types.DateTime, default=datetime.datetime.now)
updated = Column(types.DateTime, default=datetime.datetime.now)
created = Column(types.DateTime, default=datetime.datetime.utcnow)
updated = Column(types.DateTime, default=datetime.datetime.utcnow)

def __repr__(self):
summary = 'score=%s format=%s' % (self.openness_score, self.format)
Expand Down
3 changes: 2 additions & 1 deletion ckanext/qa/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import tempfile
import time
import traceback

import urlparse
import routes

Expand Down Expand Up @@ -610,7 +611,7 @@ def save_qa_result(resource, qa_result):
import ckan.model as model
from ckanext.qa.model import QA

now = datetime.datetime.now()
now = datetime.datetime.utcnow()

qa = QA.get_for_resource(resource.id)
if not qa:
Expand Down

0 comments on commit 8e10af6

Please sign in to comment.