Skip to content

Latest commit

 

History

History
192 lines (140 loc) · 3.19 KB

api.md

File metadata and controls

192 lines (140 loc) · 3.19 KB

API

Technical documentation for end developpers.

Summary

OpenedClosed

Provides store availabiltiy, near-to-close information and more.

Available since version

0.1.0

Parameters

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

Returns

OpenedClosed

Examples

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é'
  }
});

back to menu

opened

Returns true if the store is opened right now, else returns false.

Available since version

0.1.0

Parameters

None.

Returns

Boolean

Examples

const store = new OpenedClosed({
  'timezone': 'GMT+0100'
});

store.opened();

back to menu

availability

Returns "opened" or "closed" (or the equivalent set in the language options) depending the store is opened right now or not.

Available since version

0.1.0

Parameters

None.

Returns

String

Examples

const store = new OpenedClosed({
  timezone: 'GMT+0100'
});

console.log(store.availability());

back to menu

closeIn

Returns the number of seconds before the store will close.

Available since version

0.1.0

Parameters

None.

Returns

Integer

Examples

const store = new OpenedClosed({
  timezone: 'GMT+0100'
});

if(store.opened()) {
  console.log(store.closeIn());
}

back to menu

closeAt

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.

Available since version

0.1.0

Parameters

None.

Returns

Date

Examples

const store = new OpenedClosed({
  timezone: 'GMT+0100'
});

if(store.opened()) {
  console.log(store.closeAt());
}

back to menu