duckduckgo / zeroclickinfo-spice

DuckDuckGo Instant Answers based on JavaScript (JSON) APIs
https://duckduckhack.com/
Other
549 stars 942 forks source link

CitiBike: Need to normalize dates to standard format and UTC Timezone #2156

Closed moollaza closed 8 years ago

moollaza commented 9 years ago

I realized that the date string we get from the CitiBike API (https://www.citibikenyc.com/stations/json) is a non-standard date format which the new Date() constructor cannot parse. Also, it's given in EDT instead of UTC, but the string doesn't indicate the timezone, causing further problems.

@marianosimone do you know if we can get CitiBike to give us a proper, UTC formatted string? As well, can you update the code to replace the - with / then convert the time to UTC (you'll probably need to set timezone for the date to EDT first)

This way when dealing with other timezones everything will be normalized :+1:

/cc @xuv


IA Page: https://duck.co/ia/view/citi_bike_nyc

xuv commented 9 years ago

@marianosimone: Here's the line of code that worked for me to replace the - with / (on line 90):
lastCommunication: moment(new Date( (item.lastCommunicationTime).replace(/\-/g,'/') ) ).fromNow()

marianosimone commented 8 years ago

Quick update: The people behind the data feeds for CitiBike NYC (and many other bike sharing services) released a new format called GBFS, and they won't be adding features/fixing the legacy ones anymore.