Provides availabiltiy and near-to-close information from periods.
MIT License
Provides availabiltiy and near-to-close information from periods.
const OpenedClosed = require("opened-closed");
const store = new OpenedClosed({
timezone: "GMT+0100",
openings: {
monday: [
{ start: "10:00", end: "13:00" },
{ start: "15:00", end: "18:00" }
]
}
});
console.log(store.opened());
Include the following script in your project:
<script
type="text/javascript"
src="https://raw.githack.com/khalyomede/opened-closed/master/dist/opened-closed.min.js"
></script>
npm install --save opened-closed@0.*
const OpenedClosed = require('opened-closed');
All the examples can be found in the folder example
of this repository.
const OpenedClosed = require("opened-closed");
const store = new OpenedClosed({
timezone: "GMT+0100",
openings: {
monday: [
{ start: "10:00", end: "13:00" },
{ start: "15:00", end: "18:00" }
]
}
});
console.log(store.opened());
const OpenedClosed = require("opened-closed");
const store = new OpenedClosed({
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: new Date("2018-12-25 00:00:00 GMT+0100"),
to: new Date("2018-12-25 23:59:59 GMT+0100")
}
]
});
const OpenedClosed = require("opened-closed");
const store = new OpenedClosed({
timezone: "GMT+0100",
openings: {
monday: [
{ start: "10:00", end: "13:00" },
{ start: "15:00", end: "18:00" }
]
}
});
console.log(store.availability());
const OpenedClosed = require("opened-closed");
const store = new OpenedClosed({
timezone: "GMT+0100",
openings: {
monday: [
{ start: "10:00", end: "13:00" },
{ start: "15:00", end: "18:00" }
]
},
language: {
opened: "ouvert",
closed: "fermé"
}
});
console.log(store.availability());
const OpenedClosed = require("opened-closed");
const store = new OpenedClosed({
timezone: "GMT+0100",
openings: {
monday: [
{ start: "10:00", end: "13:00" },
{ start: "15:00", end: "18:00" }
]
}
});
if (store.opened()) {
console.log("closes in", store.closeIn());
} else {
console.log(store.availability());
}
const OpenedClosed = require("opened-closed");
const store = new OpenedClosed({
timezone: "GMT+0100",
openings: {
wednesday: [{ start: "10:00", end: "19:00" }]
}
});
if (store.opened()) {
const closeAt = store.closeAt().toLocaleString(); // Maybe GMT+01 is not yours, so LocalString take care of it.
console.log("will close at", closeAt);
} else {
console.log(store.availability()); // "closed"
}
src/main.ts
. This is in TypeScript, but it also support plain JavaScript if you prefer.git checkout -b issue-36
test/
npm run dev
src/main.ts
npm run test
main.ts
in opened-closed.ts
, remove the export = OpenedClosed;
linenpm run prod
Thank you for your time!