Commits

Daniel Beck committed 9476854

Fixed: time zone offsetting in the wrong direction

Comments (0)

Files changed (1)

dashboard/omnifocus/operations.py

     """Get a queryset of tasks due today."""
     utc = datetime.datetime.utcnow()
     today = datetime.datetime(year=utc.year, month=utc.month, day=utc.day,
-        hour=23, minute=59, second=59) - datetime.timedelta(minutes=offset)
+        hour=23, minute=59, second=59) + datetime.timedelta(minutes=offset)
 
-    logger.debug('Getting tasks due today (%s < tasks < %s)' % (today, utc))
+    logger.debug('Getting tasks due today: after %s and before %s)' %
+        (utc, today))
     return Task.objects.filter(due__gte=utc, due__lte=today).order_by('due')
 
 
     """Get a queryset of tasks due during tomorrow's calendar date."""
     utc = datetime.datetime.utcnow()
     today = datetime.datetime(year=utc.year, month=utc.month, day=utc.day)
-    tomorrow_start = (datetime.datetime(today.year, today.month, today.day) +
-        datetime.timedelta(days=1)) - datetime.timedelta(minutes=offset)
-    tomorrow_end = tomorrow_start + datetime.timedelta(minutes=1440,
-        seconds=-1)
+
+    start = datetime.datetime(year=utc.year, month=utc.month, day=utc.day,
+        hour=23, minute=59, second=59) + datetime.timedelta(minutes=offset)
+    end = start + datetime.timedelta(minutes=1440, seconds=-1)
 
     logger.debug('Getting tasks due tomorrow (%s < tasks < %s)' %
-        (tomorrow_start, tomorrow_end))
-    return Task.objects.filter(due__gte=tomorrow_start, due__lte=tomorrow_end)
+        (start, end))
+    return Task.objects.filter(due__gte=start, due__lte=end)
 
 
 def tasks_flagged():