django provides django.utils.timezone.now to return a timezone aware timestamp if...
authorDiane Trout <diane@ghic.org>
Fri, 17 Jan 2014 22:29:10 +0000 (14:29 -0800)
committerDiane Trout <diane@ghic.org>
Fri, 17 Jan 2014 22:29:10 +0000 (14:29 -0800)
htsworkflow/frontend/experiments/experiments.py
htsworkflow/frontend/experiments/models.py

index f24d13d5b8dc3e830b2b3c1548251886ec7f1299..9493765dcb02cf31528c295be5dd5bd5389165cf 100644 (file)
@@ -14,6 +14,7 @@ from django.core.exceptions import ObjectDoesNotExist
 from django.core.mail import send_mail, mail_admins
 from django.http import HttpResponse, Http404
 from django.conf import settings
+from django.utils import timezone
 
 from htsworkflow.frontend.auth import require_api_key
 from htsworkflow.frontend.experiments.models import \
@@ -179,7 +180,7 @@ def updStatus(request):
       rec.run_status = UpdatedStatus
 
       #if there's a message update that too
-      mytimestamp = datetime.now().__str__()
+      mytimestamp = timezone.now().__str__()
       mytimestamp = re.sub(pattern=":[^:]*$",repl="",string=mytimestamp)
       if request.REQUEST.has_key('msg'):
         rec.run_note += ", "+request.REQUEST['msg']+" ("+mytimestamp+")"
@@ -325,7 +326,7 @@ def estimateFlowcellTimeRemaining(flowcell):
     estimate_mid = estimateFlowcellDuration(flowcell)
 
     # offset for how long we've been running
-    running_time = datetime.now() - flowcell.run_date
+    running_time = timezone.now() - flowcell.run_date
     estimate_mid -= running_time
 
     return estimate_mid
index e3771cbde31be4f654fd44dc5b043ed847144257..600b9174258098488ecff81b2f75a4f61391a065 100644 (file)
@@ -9,6 +9,7 @@ import uuid
 from django.conf import settings
 from django.core.exceptions import ObjectDoesNotExist
 from django.core import urlresolvers
+from django.utils import timezone
 from django.db import models
 from django.db.models.signals import post_init, pre_save
 
@@ -219,7 +220,7 @@ class FlowCell(models.Model):
 
     def import_data_run(self, relative_pathname, run_xml_name, force=False):
         """Given a result directory import files"""
-        now = datetime.datetime.now()
+        now = timezone.now()
         run_dir = get_absolute_pathname(relative_pathname)
         run_xml_path = os.path.join(run_dir, run_xml_name)
 
@@ -253,7 +254,7 @@ class FlowCell(models.Model):
                 run.alignment_software = run_xml_data.gerald.software
                 run.alignment_version = run_xml_data.gerald.version
 
-            run.last_update_time = datetime.datetime.now()
+            run.last_update_time = timezone.now()
             run.save()
 
             run.update_result_files()
@@ -356,7 +357,7 @@ class DataRun(models.Model):
 
                     self.datafile_set.add(newfile)
 
-        self.last_update_time = datetime.datetime.now()
+        self.last_update_time = timezone.now()
 
     def lane_files(self):
         lanes = {}