File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 11import json
22import pathlib
3- from datetime import datetime
3+ from datetime import datetime , timezone
44import os
55import requests
66
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 ]
87-
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' )
85+ # search using `created_at` returns all with UTC time between 00:00-23:59 in a single day,
86+ # so it include some articles created at 20:00-00:00 in EST of the "previous day" (-04:00).
87+ # Adjust timezone info of `created_at` field into UTC time to avoid overwriting the previous day file
88+ article ['created_at' ] = article ['created_at' ][:- 3 ] + article ['created_at' ][- 2 :] # %z only accepts `-0400` instead of `-04:00` in Python3.6
89+ created_at = datetime .strptime (article ['created_at' ], '%Y-%m-%dT%H:%M:%S.%f%z' ).astimezone (timezone .utc )
90+ article ['created_at' ] = created_at .strftime ('%Y-%m-%dT%H:%M:%S.%f' )
91+ date_key = created_at .date ().strftime ('%Y%m%d' )
9192
9293 if date_key not in articles_by_date :
9394 date_articles = []
You can’t perform that action at this time.
0 commit comments