Skip to content

activeprospect/moment-range-interval

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Derive an appropriate interval from moment.js range

Resources

Stars

Watchers

Forks

Packages

No packages published