https://github.com/opentable/ot-availability-phrases
nodejs code for generating availability-phrases
https://github.com/opentable/ot-availability-phrases
Last synced: 12 months ago
JSON representation
nodejs code for generating availability-phrases
- Host: GitHub
- URL: https://github.com/opentable/ot-availability-phrases
- Owner: opentable
- License: mit
- Archived: true
- Created: 2014-12-09T17:30:34.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-09-18T15:50:02.000Z (almost 9 years ago)
- Last Synced: 2025-06-10T18:23:34.403Z (about 1 year ago)
- Language: JavaScript
- Size: 13.7 KB
- Stars: 1
- Watchers: 24
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
ot-availability-phrases
======================
[](https://travis-ci.org/opentable/ot-availability-phrases) [](http://badge.fury.io/js/ot-availability-phrases) 
Generate availability phrases from a day-schedule:
e.g.
"Mon-Fri 11:00-22:00"
installation:
```
npm install ot-availability-phrases
```
usage:
```
var builder = require('ot-availability-phrases');
var phrases = builder.getAvailabilityPhrases('en-GB', [
{
DayOfWeek: 0,
Schedule: [{
First: '09:35:00',
Last: '14:15:00'
}]
},
{
DayOfWeek: 1,
Schedule: [{
First: '09:35:00',
Last: '14:15:00'
}]
}
]);
console.log(phrases[0]);
// "Sun-Mon 09:35-14:15"
```
__getAvailabilityPhrases(locale, schedule)__
- locale: can either be a string (e.g. `en-GB`, `en`) or an array of languages (sorted by quality) `[{ code: 'en', region: 'GB', quality: 1.0}, ... ]` (as given by [accept-language-parser](https://www.npmjs.com/package/accept-language-parser)
- schedule: array of days with an array of time-ranges for each
__Running tests__
```
npm install
npm test
```