Technical documentation for end developpers.
- OpenedClosed
- OpenedClosed.opened()
- OpenedClosed.availability()
- OpenedClosed.closeIn()
- OpenedClosed.closeAt()
Provides store availabiltiy, near-to-close information and more.
0.1.0
Variable | Description | Type |
---|---|---|
options | The settings. | Object |
options.timezone | The timezone (in any format that Date supports). | String |
options.openings | The openings hours. | Object |
options.closings | The closings hours. | Array |
OpenedClosed
const store = new OpenedClosed({
timezone: 'GMT+0100',
openings: {
monday: [
{ start: '10:00', end: '13:00' },
{ start: '15:00', end: '18:00' }
],
wednesday: [
{ start: '08:00:00', end: '16:59:59' }
]
}
});
const store = new OpenedClosed({
timezone: 'GMT+0100',
openings: {
monday: [
{ start: '10:00', end: '18:00' }
]
},
closings: [
{
reason: 'Christmas',
from: new Date('2018-12-25 00:00:00 GMT+0100'),
to: new Date('2018-12-25 23:59:00 GMT+0100')
},
{
from: new Date('2018-12-31 00:00:00 GMT+0100'),
to: new Date('2019-01-01 23:59:00 GMT+0100')
}
]
});
const store = new OpenedClosed({
timezone: 'GMT+0100',
openings: {
monday: [
{ start: '10:00', end: '18:00' }
]
},
language: {
opened: 'ouvert',
closed: 'fermé'
}
});
Returns true if the store is opened right now, else returns false.
0.1.0
None.
Boolean
const store = new OpenedClosed({
'timezone': 'GMT+0100'
});
store.opened();
Returns "opened" or "closed" (or the equivalent set in the language options) depending the store is opened right now or not.
0.1.0
None.
String
const store = new OpenedClosed({
timezone: 'GMT+0100'
});
console.log(store.availability());
Returns the number of seconds before the store will close.
0.1.0
None.
Integer
const store = new OpenedClosed({
timezone: 'GMT+0100'
});
if(store.opened()) {
console.log(store.closeIn());
}
Returns a Date when the store is about to close. Note that if the store is already closed, this will return now as a Date.
0.1.0
None.
Date
const store = new OpenedClosed({
timezone: 'GMT+0100'
});
if(store.opened()) {
console.log(store.closeAt());
}