kirtanp98/mangaupdates-graphql-api

Fix date parse by including timezone

Closed this issue · 1 comments

Currently parsed dates does not include the timezone when it parses, so the time is off by a couple of hours.
dates-fns doesn't have a way to parse timezone abbreviations, so we need to figure out how we can do this.

private parseLastUpdatedDate(s: string): Date {
const timeOfDay = s.substring(s.length - 6, s.length - 4).toUpperCase();
s = s.substring(0, s.length - 6);
s += timeOfDay + ' -08:00';
return parse(s, 'MMMM do yyyy, h:mmbb xxxxx', new Date());
// fix this later, not parsing correctly

Mangaupdates looks like it sets all updated times in PST
image

August 2nd 2021, 10:22AM -08:00

gets converted properly

2021-08-02T18:22:00.000Z

The code is working as intended. This issue can be closed.