1.0.8 • Published 6 years ago

date-drift v1.0.8

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

date-drift

Increase or decrease a Date by year, month, date, hours, minutes, seconds and milliseconds.

Build Status Coverage Status install size GitHub

Install

$ npm install date-drift

Usage

var DateDrift = require('date-drift');

var df = new DateDrift(new Date('2018-9-30 10:02:04')); // default: new Date();

// support chained calls
var newDate = df.driftYears(-1).driftMonths(2).driftDays(-3).getDate();

console.log(newDate.toISOString()); // output: 2017-11-27T02:02:04.000Z

APIs

Increase/decrease years by driftYears(dYears), dYears must be an integer.

df.driftYears(dYears);

Increase/decrease months by driftMonths(dMonths), dMonths must be an integer.

df.driftMonths(dMonths);

Increase/decrease days by driftDays(dDays), dDays must be an integer.

df.driftDays(dDays);

Increase/decrease hours by driftHours(dHours), dHours must be an integer.

df.driftHours(dHours);

Increase/decrease minutes by driftMinutes(dMinutes), dMinutes must be an integer.

df.driftMinutes(dMinutes);

Increase/decrease seconds by driftSeconds(dSeconds), dSeconds must be an integer.

df.driftSeconds(dSeconds);

Increase/decrease milliseconds by driftMilliseconds(dMilliseconds), dMilliseconds must be an integer.

df.driftMilliseconds(dMilliseconds);

Get javascript Date instance.

df.getDate(); // return a Date instance.

Test

To run the test suite, first install the dependencies, then run npm test:

$ npm install
$ npm test
1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago