0.0.4 • Published 10 years ago

compress-opening-times v0.0.4

Weekly downloads
3
License
AGPL
Repository
github
Last release
10 years ago

Compress weekly opening time schedules.

var ot = require('compress-opening-times')

Serialize a list of pairs of opening and start times, where time is the number of minutes since midnight.

ot.serializeWeek([
  [ 9 * 60, 17 * 60],
  [ 9 * 60, 17 * 60],
  [ 9 * 60, 17 * 60],
  [ 9 * 60, 17 * 60],
  [ 9 * 60, 17 * 60],
  [12 * 60, 17 * 60],
    null // closed
])
// 'ġ$%Ś%ŕ'

Parse the resulting "ġ$%Ś%ŕ" to return the original list.

ot.parseWeek('ġ$%Ś%ŕ')
// [ [ 540, 1020 ],
//   [ 540, 1020 ],
//   [ 540, 1020 ],
//   [ 540, 1020 ],
//   [ 540, 1020 ],
//   [ 720, 1020 ],
//   null ]