Fix handling of dates in logs view

- Fixes #1742
- Also fixes the time zone on the aggregated logs API
This commit is contained in:
Joseph Schorr 2016-08-17 16:26:14 -04:00
parent 987bd53c2d
commit b459581637
3 changed files with 9 additions and 11 deletions

View file

@ -14,6 +14,7 @@ from auth.auth_context import get_authenticated_user
from data import model, database
from auth import scopes
from app import avatar
from tzlocal import get_localzone
LOGS_PER_PAGE = 20
SERVICE_LEVEL_LOG_KINDS = set(['service_key_create', 'service_key_approve', 'service_key_delete',
@ -41,7 +42,7 @@ def aggregated_log_view(log, kinds, start_time):
# Because we aggregate based on the day of the month in SQL, we only have that information.
# Therefore, create a synthetic date based on the day and the month of the start time.
# Logs are allowed for a maximum period of one week, so this calculation should always work.
synthetic_date = datetime(start_time.year, start_time.month, int(log.day))
synthetic_date = datetime(start_time.year, start_time.month, int(log.day), tzinfo=get_localzone())
if synthetic_date.day < start_time.day:
synthetic_date = synthetic_date + relativedelta(months=1)