0.0.1 • Published 6 years ago

moment-math v0.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

Documentation

This module is created mainly to optimize some simple, but repetitive tasks to a module for moment development.

$ npm install moment-math --save
const mm = require('moment-math');

const result = mm.gt('2017/01/02', '2018/02/03');
// moment(2018-02-03)

// .. in production

gt

  • return the greater value between two moment dates
const result = mm.gt('2017/01/02', '2018/02/03');
// moment(2017/02/03)

lt

  • return the lesser value between two moment dates
const result = mm.lt('2017/01/02', '2018/02/03');
// moment(2017/01/02)

range

  • create a range array between two moment dates
const result = mm.range('2017/01/01', '2018/01/03');
// [moment(2017/01/01), moment(2017/01/02), moment(2017/01/03)]

date failover

  • failover to second date if first doesn't exist
const result = mm.dateFailover(null, '2018/01/03');
// moment(2018/01/03)