Opened Closed
Provides availabiltiy and near-to-close information from periods.
const OpenedClosed = ; const store = timezone: "GMT+0100" openings: monday: start: "10:00" end: "13:00" start: "15:00" end: "18:00" ; console;
Summary
Installation
Web
Include the following script in your project:
NPM
- Include Opened Closed in your dependencies:
npm install --save opened-closed@0.*
- Import it in your script:
const OpenedClosed = require;
Usage
All the examples can be found in the folder example
of this repository.
- Example 1: checking if a store is opened now
- Example 2: adding exceptional closings dates
- Example 3: getting the opening state as a string
- Example 4: changing the language
- Example 5: get the "store closes in" in seconds
- Example 6: get the "store closes in" as a date
Example 1: checking if a store is opened now
const OpenedClosed = ; const store = timezone: "GMT+0100" openings: monday: start: "10:00" end: "13:00" start: "15:00" end: "18:00" ; console;
Example 2: adding exceptional closings dates
const OpenedClosed = ; const store = timezone: "GMT+0100" openings: monday: start: "10:00" end: "13:00" start: "15:00" end: "18:00" tuesday: start: "10:00" end: "13:00" start: "15:00" end: "18:00" closings: reason: "Christmas" // optional from: "2018-12-25 00:00:00 GMT+0100" to: "2018-12-25 23:59:59 GMT+0100" ;
Example 3: getting the opening state as a string
const OpenedClosed = ; const store = timezone: "GMT+0100" openings: monday: start: "10:00" end: "13:00" start: "15:00" end: "18:00" ; console;
Example 4: changing the language
const OpenedClosed = ; const store = timezone: "GMT+0100" openings: monday: start: "10:00" end: "13:00" start: "15:00" end: "18:00" language: opened: "ouvert" closed: "fermé" ; console;
Example 5: get the store closes in in seconds
const OpenedClosed = ; const store = timezone: "GMT+0100" openings: monday: start: "10:00" end: "13:00" start: "15:00" end: "18:00" ; if store console; else console;
Example 6: get the store closes in as a date
const OpenedClosed = ; const store = timezone: "GMT+0100" openings: wednesday: start: "10:00" end: "19:00" ; if store const closeAt = store; // Maybe GMT+01 is not yours, so LocalString take care of it. console; else console; // "closed"
Contributing
- The code is located in
src/main.ts
. This is in TypeScript, but it also support plain JavaScript if you prefer. - I prefer no dependencies for the moment, because this is help making a working web solution (opened to suggestions to improve the workflow).
- The web solution is simply removing the export statement, and using Gulp to transpile TypeScript in ES5 (opened to suggestions to improve the workflow).
- Create an issue
- Create a branche with the number of the issue in it:
git checkout -b issue-36
- Create tests inside
test/
- Light on dev:
npm run dev
- Make your changes on
src/main.ts
- Run test using
npm run test
- Copy
main.ts
inopened-closed.ts
, remove theexport = OpenedClosed;
line - Run
npm run prod
- Create a Pull Request from your branch to master
Thank you for your time!