node package manager
Painless code sharing. npm Orgs help your team discover, share, and reuse code. Create a free org »

ot-availability-phrases

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