Skip to content

Commit 9c20a9f

Browse files
committed
last_updated changed to iso format
1 parent 8250bf7 commit 9c20a9f

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ GET /v2/locations?source=csbs
144144
"country_code": "US",
145145
"county": "New York",
146146
"id": 0,
147-
"last_updated": "2020-03-21 14:00 EDT",
147+
"last_updated": "2020-03-21T14:00:00Z",
148148
"latest": {
149149
"confirmed": 6211,
150150
"deaths": 43,
@@ -162,7 +162,7 @@ GET /v2/locations?source=csbs
162162
"country_code": "US",
163163
"county": "Westchester",
164164
"id": 1,
165-
"last_updated": "2020-03-21 14:00 EDT",
165+
"last_updated": "2020-03-21T14:00:00Z",
166166
"latest": {
167167
"confirmed": 1385,
168168
"deaths": 0,

app/services/location/csbs.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,20 @@ def get_locations():
4646
confirmed = int(item['Confirmed'] or 0)
4747
death = int(item['Death'] or 0)
4848
coordinates = Coordinates(float(item['Latitude']), float(item['Longitude']))
49+
50+
# Parse time to ISO format
4951
last_update = item['Last Update']
52+
date = last_update.split("-")
53+
year = int(date[0])
54+
month = int(date[1])
55+
date = date[2].split(" ")
56+
day = int(date[0])
57+
time = date[1].split(":")
58+
hour = int(time[0])
59+
minute = int(time[1])
60+
d = datetime(year=year, month=month, day=day, hour=hour, minute=minute)
61+
last_update = d.isoformat() + 'Z'
62+
5063
locations.append(CSBSLocation(i, state, county, coordinates, last_update, confirmed, death))
5164

5265
return locations

0 commit comments

Comments
 (0)