google-places-periods-parser
Transforms opening hours data from Google Places into the schema.org/OpeningHoursSpecification format.
- Zero dependencies
- Typescript
- Even has a few unit tests
Why would I want this?
When retrieving opening hours data from the Google Maps API you will notice the data looks like this:
There are already plenty of libraries available for parsing opening hours, but I couldn't find any that worked with this format.
Instead of writing another parser, this library transform the data into another format -- the OpeningHoursSpecification.
/*result === [{ dayOfWeek: [ 'sunday', 'saturday' ], opens: '08:30', closes: '14:30'},{ dayOfWeek: [ 'monday', 'tuesday', 'wednesday', 'thursday', 'friday' ], opens: '07:30', closes: '14:30'}]*/
But are they open?
This library won't tell if you a store is open. I recommend you use
openinghours.js
to find this
out.
/*state === { isOpen: true, closesAt: new Date("2019-12-05T14:00:00.000Z")}*/