I'm using an API to query Google News and then store the results in Firestore.
Unfortunately the API returns non-uniform timestamp formats. Example: "1 Day Ago", "June 1, 2021", "4 Days Ago", "1 Week Ago", "1 Month Ago", etc.
I'd like to transform these dates to a uniform format before writing to Firestore so that I can easily sort them by date when calling to Firestore from the client.
I love to avoid writing custom conversion logic for each date format. Does anyone know of a library or off the shelf solution to make this simpler?
Here's my node code so far:
request(options, function(error, response) {
if (error) throw new Error(error);
const response = JSON.parse(response.body);
const parsedResponse = Response["news_results"];
for (let i=0; i<parsedResponse.length; i++) {
// console.log(i);
db.collection("articles").add(parsedResponse[i]);
}
});