ot-availability-phrases

Utility functions for dealing with availability phrases

Usage no npm install needed!

<script type="module">
  import otAvailabilityPhrases from 'https://cdn.skypack.dev/ot-availability-phrases';
</script>

README

ot-availability-phrases

Build Status NPM version Dependencies

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

  • schedule: array of days with an array of time-ranges for each

Running tests

npm install
npm test