Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the timezone issues when pulling records from file db. #829

Merged
merged 2 commits into from
May 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions bin/peas_shell
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import os
import readline
import sys

from pytz import utc
from astropy.utils import console
from threading import Timer
from pprint import pprint
Expand Down Expand Up @@ -75,9 +76,12 @@ class PanSensorShell(cmd.Cmd):
print("{}:".format(device.upper()))
pprint(rec)
print_info('*' * 80)

# Display the age in seconds of the record
if isinstance(rec.get('date'), datetime.datetime):
now = current_time(datetime=True)
age = (now - rec['date']).total_seconds()
now = current_time(datetime=True).astimezone(utc)
record_date = rec['date'].astimezone(utc)
age = (now - record_date).total_seconds()
if age < 120:
print_info('{:.1f} seconds old'.format(age))
else:
Expand Down