update format_date to handle December
This commit is contained in:
parent
28eb31ed36
commit
a967340aad
1 changed files with 5 additions and 5 deletions
|
@ -3,6 +3,7 @@
|
|||
import json
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from endpoints.api import (resource, nickname, ApiResource, query_param, parse_args,
|
||||
RepositoryParamResource, require_repo_admin, related_user_resource,
|
||||
|
@ -39,15 +40,14 @@ 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.
|
||||
day = int(log.day)
|
||||
month = start_time.month
|
||||
if day < start_time.day:
|
||||
month = month + 1
|
||||
synthetic_date = datetime(start_time.year, start_time.month, int(log.day))
|
||||
if synthetic_date.day < start_time.day:
|
||||
synthetic_date = synthetic_date + relativedelta(months=1)
|
||||
|
||||
view = {
|
||||
'kind': kinds[log.kind_id],
|
||||
'count': log.count,
|
||||
'datetime': format_date(datetime(start_time.year, month, day))
|
||||
'datetime': format_date(synthetic_date),
|
||||
}
|
||||
|
||||
return view
|
||||
|
|
Reference in a new issue