1.0.0 • Published 7 years ago

moment-range-interval v1.0.0

Weekly downloads
22
License
ISC
Repository
github
Last release
7 years ago

Moment Range Interval

Derive an interval string from a moment range.

Build Status

Installation

npm install moment-range-interval --save

Usage

This library examines a moment range and determines an appropriate time series interval to use for the range.

const moment      = require('moment-range').extendMoment(require('moment')),
      getInterval = require('moment-range-interval');

const interval = getInterval(moment.range('2017-10-24T00:00:00.000', '2017-10-28T23:59:59.999'));

console.log(interval);
// =>
// days

How it works

The interval with the highest possible resolution will be selected for the specified range. The default resolution (60) will get you 60 "buckets" of data or fewer.

The supported intervals are:

  • minutes
  • hours
  • days
  • weeks
  • months
  • years