From 89e744a4de227dc36f3bdb9f4183a986ef624419 Mon Sep 17 00:00:00 2001 From: Dan Braghis <dan.braghis@torchbox.com> Date: Thu, 8 Mar 2018 14:10:28 +0000 Subject: [PATCH] Import dates with timezone --- .../funds/management/commands/migrate_rr_applications.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opentech/apply/funds/management/commands/migrate_rr_applications.py b/opentech/apply/funds/management/commands/migrate_rr_applications.py index ab4d4ed75..ab9a1cd2c 100644 --- a/opentech/apply/funds/management/commands/migrate_rr_applications.py +++ b/opentech/apply/funds/management/commands/migrate_rr_applications.py @@ -1,7 +1,7 @@ import argparse import json -from datetime import datetime +from datetime import datetime, timezone from django.contrib.auth import get_user_model from django.core.management.base import BaseCommand @@ -252,7 +252,7 @@ class Command(BaseCommand): submission = ApplicationSubmission(drupal_id=node['nid']) # TODO timezone? - submission.submit_time = datetime.utcfromtimestamp(int(node['created'])) + submission.submit_time = datetime.fromtimestamp(int(node['created']), timezone.utc) submission.user = self.get_user(node['uid']) submission.page = FUND @@ -271,6 +271,7 @@ class Command(BaseCommand): try: submission.save() + self.stdout.write(f"Processed \"{node['title']}\" ({node['nid']})") except IntegrityError: pass -- GitLab