Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
last_updated changed to iso format
  • Loading branch information
JKSenthil committed Mar 21, 2020
commit 9c20a9f60314cf3d8d88bbda40aae4df14525c02
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ GET /v2/locations?source=csbs
"country_code": "US",
"county": "New York",
"id": 0,
"last_updated": "2020-03-21 14:00 EDT",
"last_updated": "2020-03-21T14:00:00Z",
"latest": {
"confirmed": 6211,
"deaths": 43,
Expand All @@ -162,7 +162,7 @@ GET /v2/locations?source=csbs
"country_code": "US",
"county": "Westchester",
"id": 1,
"last_updated": "2020-03-21 14:00 EDT",
"last_updated": "2020-03-21T14:00:00Z",
"latest": {
"confirmed": 1385,
"deaths": 0,
Expand Down
13 changes: 13 additions & 0 deletions app/services/location/csbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,20 @@ def get_locations():
confirmed = int(item['Confirmed'] or 0)
death = int(item['Death'] or 0)
coordinates = Coordinates(float(item['Latitude']), float(item['Longitude']))

# Parse time to ISO format
last_update = item['Last Update']
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be parsed as ISO with an added 'Z' at the end. Use import datetime from datetime to achieve this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

date = last_update.split("-")
year = int(date[0])
month = int(date[1])
date = date[2].split(" ")
day = int(date[0])
time = date[1].split(":")
hour = int(time[0])
minute = int(time[1])
d = datetime(year=year, month=month, day=day, hour=hour, minute=minute)
last_update = d.isoformat() + 'Z'

locations.append(CSBSLocation(i, state, county, coordinates, last_update, confirmed, death))

return locations