Skip to content

Commit 4a94fb4

Browse files
committed
Update timezone info in processor and data class
1 parent ae9ad39 commit 4a94fb4

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

RegalyticsRegulatoryArticle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public override List<Resolution> SupportedResolutions()
199199
/// <returns>The <see cref="T:NodaTime.DateTimeZone" /> of this data type</returns>
200200
public override DateTimeZone DataTimeZone()
201201
{
202-
return TimeZones.NewYork;
202+
return TimeZones.Utc;
203203
}
204204
}
205205
}

process.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
import pathlib
3-
from datetime import datetime
3+
from datetime import datetime, timedelta
44
import os
55
import requests
66

@@ -82,12 +82,21 @@
8282
article['states'] = states
8383
article['agencies'] = [agency['name'] for agency in article['agencies']]
8484

85-
# remove timezone info (-04:00) [NewYork]
86-
article['created_at'] = article['created_at'][:-6]
85+
# adjust timezone info (e.g. -04:00) into UTC time
86+
timezone_adjust = article['created_at'][-5:]
87+
plus_or_minus = article['created_at'][-6]
88+
timezone_adjust = datetime.strptime(timezone_adjust, "%H:%M")
89+
timedelta_adjust = timedelta(hours=timezone_adjust.hour, minutes=timezone_adjust.minute)
8790

88-
# all data received during day T would confer into day T+1 00:00
89-
date = datetime.strptime(article['created_at'], '%Y-%m-%dT%H:%M:%S.%f').date()
90-
date_key = date.strftime('%Y%m%d')
91+
created_at = datetime.strptime(article['created_at'][:-6], '%Y-%m-%dT%H:%M:%S.%f')
92+
if plus_or_minus == "+":
93+
created_at -= timedelta_adjust
94+
elif plus_or_minus == "-":
95+
created_at += timedelta_adjust
96+
97+
# all data received during day T would confer into bar of Time = Day T 00:00; EndTime = Day T+1 00:00 at UTC time
98+
date_key = created_at.date().strftime('%Y%m%d')
99+
article['created_at'] = created_at.strftime('%Y-%m-%dT%H:%M:%S.%f') # UTC Time
91100

92101
if date_key not in articles_by_date:
93102
date_articles = []

0 commit comments

Comments
 (0)