Latest repo

This commit is contained in:
Marc
2025-06-02 16:42:16 +00:00
parent 53ddf1a329
commit cde5fae175
27907 changed files with 3875388 additions and 1 deletions

22
node_modules/date-arithmetic/.gitattributes generated vendored Normal file
View File

@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

27
node_modules/date-arithmetic/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,27 @@
# [4.1.0](https://github.com/jquense/date-math/compare/v4.0.1...v4.1.0) (2020-01-02)
### Bug Fixes
* add month on leap year ([2857325](https://github.com/jquense/date-math/commit/28573254a1600624a3df1215fc5fb7dc3e42eda0))
### Features
* add solveDST function ([44b425d](https://github.com/jquense/date-math/commit/44b425dbbd41777939338623b86533bae23b9082))
## [4.0.1](https://github.com/jquense/date-math/compare/v4.0.0...v4.0.1) (2019-06-26)
### Bug Fixes
* month math ([2de5015](https://github.com/jquense/date-math/commit/2de5015)), closes [#17](https://github.com/jquense/date-math/issues/17)

21
node_modules/date-arithmetic/License.txt generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Jason Quense
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

65
node_modules/date-arithmetic/README.md generated vendored Normal file
View File

@@ -0,0 +1,65 @@
Date Arthmetic
=================
A simple object containing some date math utils in the spirit of Moment.js. Unlike Moment this module, returns real date objects, so it isn't chainable.
import * as dateMath from 'date-arithmetic'
var date = dateMath.month(new Date)
## API
all api methods return a _new_ date. Date objects are never mutated.
### Accessors
get and set date part values.
- `dateMath.milliseconds(date, [value])`
- `dateMath.seconds(date, [value])`
- `dateMath.minutes(date, [value])`
- `dateMath.hours(date, [value])`
- `dateMath.date(date, [value])`
- `dateMath.day(date, [value])`
- `dateMath.weekday(date, [value], [firstOfWeek = 0])`
- `dateMath.month(date, [value])`
- `dateMath.year(date, [value])`
- `dateMath.decade(date, [value])`
- `dateMath.century(date, [value])`
### `startOf(data, unit, [firstOfWeek = 0])`
return a new date with the relevent date parts zero'd out. You only need to provide a `firstOfWeek` when the unit is `'week'`
dateMath.startOf(new Date, 'day') // -> no time components
Valid unit values are; `"seconds", "minutes", "hours", "day", "week", "month", "year", "decade", "century" `
### `endOf(data, unit)`
the opposite of `startOf`
dateMath.endOf(new Date, 'day') // -> one millisecond before tomorrow
Valid unit values are; `"milliseconds", "seconds", "minutes", "hours", "day", "weekday", "month", "year", "decade", "century"`.
### Math Functions
Arithmetic functions
- `dateMath.add(date, value, unit)`
- `dateMath.subtract(date, value, unit)`
- `dateMath.eq(dateA, dateB, [unit])`
- `dateMath.neq(dateA, dateB, [unit])`
- `dateMath.gte(dateA, dateB, [unit])`
- `dateMath.gt(dateA, dateB, [unit])`
- `dateMath.lte(dateA, dateB, [unit])`
- `dateMath.lt(dateA, dateB, [unit])`
- `dateMath.inRange(day, min, max, unit)`
- `dateMath.min(dateA, dateB, dateN)`
- `dateMath.max(dateA, dateB, dateN)`
- `dateMath.diff(dateA, dateB, unit, asFloat)`
Valid unit values are; `"seconds", "minutes", "hours", "day", "week", "month", "year", "decade", "century" `

330
node_modules/date-arithmetic/index.cjs.js generated vendored Normal file
View File

@@ -0,0 +1,330 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var MILI = 'milliseconds'
, SECONDS = 'seconds'
, MINUTES = 'minutes'
, HOURS = 'hours'
, DAY = 'day'
, WEEK = 'week'
, MONTH = 'month'
, YEAR = 'year'
, DECADE = 'decade'
, CENTURY = 'century';
var multiplierMilli = {
'milliseconds': 1,
'seconds': 1000,
'minutes': 60 * 1000,
'hours': 60 * 60 * 1000,
'day': 24 * 60 * 60 * 1000,
'week': 7 * 24 * 60 * 60 * 1000
};
var multiplierMonth = {
'month': 1,
'year': 12,
'decade': 10 * 12,
'century': 100 * 12
};
function daysOf(year) {
return [31, daysInFeb(year), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
}
function daysInFeb(year) {
return (
year % 4 === 0
&& year % 100 !== 0
) || year % 400 === 0
? 29
: 28
}
function add(d, num, unit) {
d = new Date(d);
switch (unit){
case MILI:
case SECONDS:
case MINUTES:
case HOURS:
case DAY:
case WEEK:
return addMillis(d, num * multiplierMilli[unit])
case MONTH:
case YEAR:
case DECADE:
case CENTURY:
return addMonths(d, num * multiplierMonth[unit])
}
throw new TypeError('Invalid units: "' + unit + '"')
}
function addMillis(d, num) {
var nextDate = new Date(+(d) + num);
return solveDST(d, nextDate)
}
function addMonths(d, num) {
var year = d.getFullYear()
, month = d.getMonth()
, day = d.getDate()
, totalMonths = year * 12 + month + num
, nextYear = Math.trunc(totalMonths / 12)
, nextMonth = totalMonths % 12
, nextDay = Math.min(day, daysOf(nextYear)[nextMonth]);
var nextDate = new Date(d);
nextDate.setFullYear(nextYear);
// To avoid a bug when sets the Feb month
// with a date > 28 or date > 29 (leap year)
nextDate.setDate(1);
nextDate.setMonth(nextMonth);
nextDate.setDate(nextDay);
return nextDate
}
function solveDST(currentDate, nextDate) {
var currentOffset = currentDate.getTimezoneOffset()
, nextOffset = nextDate.getTimezoneOffset();
// if is DST, add the difference in minutes
// else the difference is zero
var diffMinutes = (nextOffset - currentOffset);
return new Date(+(nextDate) + diffMinutes * multiplierMilli['minutes'])
}
function subtract(d, num, unit) {
return add(d, -num, unit)
}
function startOf(d, unit, firstOfWeek) {
d = new Date(d);
switch (unit) {
case CENTURY:
case DECADE:
case YEAR:
d = month(d, 0);
case MONTH:
d = date(d, 1);
case WEEK:
case DAY:
d = hours(d, 0);
case HOURS:
d = minutes(d, 0);
case MINUTES:
d = seconds(d, 0);
case SECONDS:
d = milliseconds(d, 0);
}
if (unit === DECADE)
d = subtract(d, year(d) % 10, 'year');
if (unit === CENTURY)
d = subtract(d, year(d) % 100, 'year');
if (unit === WEEK)
d = weekday(d, 0, firstOfWeek);
return d
}
function endOf(d, unit, firstOfWeek){
d = new Date(d);
d = startOf(d, unit, firstOfWeek);
switch (unit) {
case CENTURY:
case DECADE:
case YEAR:
case MONTH:
case WEEK:
d = add(d, 1, unit);
d = subtract(d, 1, DAY);
d.setHours(23, 59, 59, 999);
break;
case DAY:
d.setHours(23, 59, 59, 999);
break;
case HOURS:
case MINUTES:
case SECONDS:
d = add(d, 1, unit);
d = subtract(d, 1, MILI);
}
return d
}
var eq = createComparer(function(a, b){ return a === b });
var neq = createComparer(function(a, b){ return a !== b });
var gt = createComparer(function(a, b){ return a > b });
var gte = createComparer(function(a, b){ return a >= b });
var lt = createComparer(function(a, b){ return a < b });
var lte = createComparer(function(a, b){ return a <= b });
function min(){
return new Date(Math.min.apply(Math, arguments))
}
function max(){
return new Date(Math.max.apply(Math, arguments))
}
function inRange(day, min, max, unit){
unit = unit || 'day';
return (!min || gte(day, min, unit))
&& (!max || lte(day, max, unit))
}
var milliseconds = createAccessor('Milliseconds');
var seconds = createAccessor('Seconds');
var minutes = createAccessor('Minutes');
var hours = createAccessor('Hours');
var day = createAccessor('Day');
var date = createAccessor('Date');
var month = createAccessor('Month');
var year = createAccessor('FullYear');
function decade(d, val) {
return val === undefined
? year(startOf(d, DECADE))
: add(d, val + 10, YEAR);
}
function century(d, val) {
return val === undefined
? year(startOf(d, CENTURY))
: add(d, val + 100, YEAR);
}
function weekday(d, val, firstDay) {
var w = (day(d) + 7 - (firstDay || 0) ) % 7;
return val === undefined
? w
: add(d, val - w, DAY);
}
function diff(date1, date2, unit, asFloat) {
var dividend, divisor, result;
switch (unit) {
case MILI:
case SECONDS:
case MINUTES:
case HOURS:
case DAY:
case WEEK:
dividend = date2.getTime() - date1.getTime(); break;
case MONTH:
case YEAR:
case DECADE:
case CENTURY:
dividend = (year(date2) - year(date1)) * 12 + month(date2) - month(date1); break;
default:
throw new TypeError('Invalid units: "' + unit + '"');
}
switch (unit) {
case MILI:
divisor = 1; break;
case SECONDS:
divisor = 1000; break;
case MINUTES:
divisor = 1000 * 60; break;
case HOURS:
divisor = 1000 * 60 * 60; break;
case DAY:
divisor = 1000 * 60 * 60 * 24; break;
case WEEK:
divisor = 1000 * 60 * 60 * 24 * 7; break;
case MONTH:
divisor = 1; break;
case YEAR:
divisor = 12; break;
case DECADE:
divisor = 120; break;
case CENTURY:
divisor = 1200; break;
default:
throw new TypeError('Invalid units: "' + unit + '"');
}
result = dividend / divisor;
return asFloat ? result : Math.round(result);
}
function createAccessor(method){
var hourLength = (function(method) {
switch(method) {
case 'Milliseconds':
return 3600000;
case 'Seconds':
return 3600;
case 'Minutes':
return 60;
case 'Hours':
return 1;
default:
return null;
}
})(method);
return function(d, val){
if (val === undefined)
return d['get' + method]()
var dateOut = new Date(d);
dateOut['set' + method](val);
if(hourLength && dateOut['get'+method]() != val && (method === 'Hours' || val >=hourLength && (dateOut.getHours()-d.getHours()<Math.floor(val/hourLength))) ){
//Skip DST hour, if it occurs
dateOut['set'+method](val+hourLength);
}
return dateOut
}
}
function createComparer(operator) {
return function (a, b, unit) {
return operator(+startOf(a, unit), +startOf(b, unit))
};
}
exports.add = add;
exports.century = century;
exports.date = date;
exports.day = day;
exports.decade = decade;
exports.diff = diff;
exports.endOf = endOf;
exports.eq = eq;
exports.gt = gt;
exports.gte = gte;
exports.hours = hours;
exports.inRange = inRange;
exports.lt = lt;
exports.lte = lte;
exports.max = max;
exports.milliseconds = milliseconds;
exports.min = min;
exports.minutes = minutes;
exports.month = month;
exports.neq = neq;
exports.seconds = seconds;
exports.startOf = startOf;
exports.subtract = subtract;
exports.weekday = weekday;
exports.year = year;

300
node_modules/date-arithmetic/index.js generated vendored Normal file
View File

@@ -0,0 +1,300 @@
var MILI = 'milliseconds'
, SECONDS = 'seconds'
, MINUTES = 'minutes'
, HOURS = 'hours'
, DAY = 'day'
, WEEK = 'week'
, MONTH = 'month'
, YEAR = 'year'
, DECADE = 'decade'
, CENTURY = 'century';
var multiplierMilli = {
'milliseconds': 1,
'seconds': 1000,
'minutes': 60 * 1000,
'hours': 60 * 60 * 1000,
'day': 24 * 60 * 60 * 1000,
'week': 7 * 24 * 60 * 60 * 1000
}
var multiplierMonth = {
'month': 1,
'year': 12,
'decade': 10 * 12,
'century': 100 * 12
}
function daysOf(year) {
return [31, daysInFeb(year), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
}
function daysInFeb(year) {
return (
year % 4 === 0
&& year % 100 !== 0
) || year % 400 === 0
? 29
: 28
}
export function add(d, num, unit) {
d = new Date(d)
switch (unit){
case MILI:
case SECONDS:
case MINUTES:
case HOURS:
case DAY:
case WEEK:
return addMillis(d, num * multiplierMilli[unit])
case MONTH:
case YEAR:
case DECADE:
case CENTURY:
return addMonths(d, num * multiplierMonth[unit])
}
throw new TypeError('Invalid units: "' + unit + '"')
}
function addMillis(d, num) {
var nextDate = new Date(+(d) + num)
return solveDST(d, nextDate)
}
function addMonths(d, num) {
var year = d.getFullYear()
, month = d.getMonth()
, day = d.getDate()
, totalMonths = year * 12 + month + num
, nextYear = Math.trunc(totalMonths / 12)
, nextMonth = totalMonths % 12
, nextDay = Math.min(day, daysOf(nextYear)[nextMonth])
var nextDate = new Date(d)
nextDate.setFullYear(nextYear)
// To avoid a bug when sets the Feb month
// with a date > 28 or date > 29 (leap year)
nextDate.setDate(1)
nextDate.setMonth(nextMonth)
nextDate.setDate(nextDay)
return nextDate
}
function solveDST(currentDate, nextDate) {
var currentOffset = currentDate.getTimezoneOffset()
, nextOffset = nextDate.getTimezoneOffset()
// if is DST, add the difference in minutes
// else the difference is zero
var diffMinutes = (nextOffset - currentOffset)
return new Date(+(nextDate) + diffMinutes * multiplierMilli['minutes'])
}
export function subtract(d, num, unit) {
return add(d, -num, unit)
}
export function startOf(d, unit, firstOfWeek) {
d = new Date(d)
switch (unit) {
case CENTURY:
case DECADE:
case YEAR:
d = month(d, 0);
case MONTH:
d = date(d, 1);
case WEEK:
case DAY:
d = hours(d, 0);
case HOURS:
d = minutes(d, 0);
case MINUTES:
d = seconds(d, 0);
case SECONDS:
d = milliseconds(d, 0);
}
if (unit === DECADE)
d = subtract(d, year(d) % 10, 'year')
if (unit === CENTURY)
d = subtract(d, year(d) % 100, 'year')
if (unit === WEEK)
d = weekday(d, 0, firstOfWeek);
return d
}
export function endOf(d, unit, firstOfWeek){
d = new Date(d)
d = startOf(d, unit, firstOfWeek)
switch (unit) {
case CENTURY:
case DECADE:
case YEAR:
case MONTH:
case WEEK:
d = add(d, 1, unit)
d = subtract(d, 1, DAY)
d.setHours(23, 59, 59, 999)
break;
case DAY:
d.setHours(23, 59, 59, 999)
break;
case HOURS:
case MINUTES:
case SECONDS:
d = add(d, 1, unit)
d = subtract(d, 1, MILI)
}
return d
}
export var eq = createComparer(function(a, b){ return a === b })
export var neq = createComparer(function(a, b){ return a !== b })
export var gt = createComparer(function(a, b){ return a > b })
export var gte = createComparer(function(a, b){ return a >= b })
export var lt = createComparer(function(a, b){ return a < b })
export var lte = createComparer(function(a, b){ return a <= b })
export function min(){
return new Date(Math.min.apply(Math, arguments))
}
export function max(){
return new Date(Math.max.apply(Math, arguments))
}
export function inRange(day, min, max, unit){
unit = unit || 'day'
return (!min || gte(day, min, unit))
&& (!max || lte(day, max, unit))
}
export var milliseconds = createAccessor('Milliseconds')
export var seconds = createAccessor('Seconds')
export var minutes = createAccessor('Minutes')
export var hours = createAccessor('Hours')
export var day = createAccessor('Day')
export var date = createAccessor('Date')
export var month = createAccessor('Month')
export var year = createAccessor('FullYear')
export function decade(d, val) {
return val === undefined
? year(startOf(d, DECADE))
: add(d, val + 10, YEAR);
}
export function century(d, val) {
return val === undefined
? year(startOf(d, CENTURY))
: add(d, val + 100, YEAR);
}
export function weekday(d, val, firstDay) {
var w = (day(d) + 7 - (firstDay || 0) ) % 7;
return val === undefined
? w
: add(d, val - w, DAY);
}
export function diff(date1, date2, unit, asFloat) {
var dividend, divisor, result;
switch (unit) {
case MILI:
case SECONDS:
case MINUTES:
case HOURS:
case DAY:
case WEEK:
dividend = date2.getTime() - date1.getTime(); break;
case MONTH:
case YEAR:
case DECADE:
case CENTURY:
dividend = (year(date2) - year(date1)) * 12 + month(date2) - month(date1); break;
default:
throw new TypeError('Invalid units: "' + unit + '"');
}
switch (unit) {
case MILI:
divisor = 1; break;
case SECONDS:
divisor = 1000; break;
case MINUTES:
divisor = 1000 * 60; break;
case HOURS:
divisor = 1000 * 60 * 60; break;
case DAY:
divisor = 1000 * 60 * 60 * 24; break;
case WEEK:
divisor = 1000 * 60 * 60 * 24 * 7; break;
case MONTH:
divisor = 1; break;
case YEAR:
divisor = 12; break;
case DECADE:
divisor = 120; break;
case CENTURY:
divisor = 1200; break;
default:
throw new TypeError('Invalid units: "' + unit + '"');
}
result = dividend / divisor;
return asFloat ? result : Math.round(result);
}
function createAccessor(method){
var hourLength = (function(method) {
switch(method) {
case 'Milliseconds':
return 3600000;
case 'Seconds':
return 3600;
case 'Minutes':
return 60;
case 'Hours':
return 1;
default:
return null;
}
})(method);
return function(d, val){
if (val === undefined)
return d['get' + method]()
var dateOut = new Date(d)
dateOut['set' + method](val)
if(hourLength && dateOut['get'+method]() != val && (method === 'Hours' || val >=hourLength && (dateOut.getHours()-d.getHours()<Math.floor(val/hourLength))) ){
//Skip DST hour, if it occurs
dateOut['set'+method](val+hourLength);
}
return dateOut
}
}
function createComparer(operator) {
return function (a, b, unit) {
return operator(+startOf(a, unit), +startOf(b, unit))
};
}

34
node_modules/date-arithmetic/package.json generated vendored Normal file
View File

@@ -0,0 +1,34 @@
{
"name": "date-arithmetic",
"version": "4.1.0",
"description": "simple date math util",
"main": "index.cjs.js",
"module": "index.js",
"scripts": {
"test": "node -r esm test.js",
"prepublishOnly": "rollup --input index.js --file index.cjs.js --format cjs"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jquense/date-math.git"
},
"keywords": [
"moment",
"date",
"math"
],
"author": {
"name": "Jason Quense @monasticpanic"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/jquense/date-math/issues"
},
"homepage": "https://github.com/jquense/date-math",
"devDependencies": {
"esm": "^3.2.25",
"rollup": "^1.14.4"
},
"readme": "ERROR: No README data found!",
"_id": "date-arithmetic@4.0.1"
}

158
node_modules/date-arithmetic/test.js generated vendored Normal file
View File

@@ -0,0 +1,158 @@
import assert from 'assert'
import * as dateMath from './index'
var date = new Date(
2014 /* year */
, 1 /* month */
, 18 /* day */
, 8 /* hour */
, 25 /* min */
, 30 /* sec */
, 5); /* ms */
var dateLeapYearOnFeb = new Date(
2016 /* year */
, 1 /* month */
, 29 /* day */
, 8 /* hour */
, 25 /* min */
, 30 /* sec */
, 5); /* ms */
var dateLeapYear = new Date(
2016 /* year */
, 0 /* month */
, 31 /* day */
, 8 /* hour */
, 25 /* min */
, 30 /* sec */
, 5); /* ms */
var beforeDaylightSavingTime = new Date(
2017 /* year */
, 2 /* month */
, 25 /* day */
, 12 /* hour */
, 0 /* min */
, 0 /* sec */
, 0); /* ms */
var afterDaylightSavingTime = new Date(
2017 /* year */
, 2 /* month */
, 26 /* day */
, 12 /* hour */
, 0 /* min */
, 0 /* sec */
, 0); /* ms */
console.log('---- Accessors ----------------------------')
//accessors
assert.equal(dateMath.year(date), 2014, 'year is equal to 2014')
assert.equal(dateMath.month(date), 1, 'month is equal to 1')
assert.equal(dateMath.date(date), 18, 'date is equal to 18')
assert.equal(dateMath.day(date), 2, 'day is equal to 2')
assert.equal(dateMath.hours(date), 8, 'hour is equal to 8')
assert.equal(dateMath.minutes(date), 25, 'minute is equal to 25')
assert.equal(dateMath.seconds(date), 30, 'seconds is equal to 30')
assert.equal(dateMath.milliseconds(date), 5, 'ms is equal to 5')
console.log(' passed')
console.log('---- start of ----------------------------')
assert.equal(+dateMath.startOf(date, 'year'), +(new Date(2014,0,1,0,0,0,0)), 'startOf year')
assert.equal(+dateMath.startOf(date, 'month'), +(new Date(2014,1,1,0,0,0,0)), 'startOf month')
assert.equal(+dateMath.startOf(date, 'day'), +(new Date(2014,1,18,0,0,0,0)), 'startOf day')
assert.equal(+dateMath.startOf(date, 'week'), +(new Date(2014,1,16,0,0,0,0)), 'startOf week')
assert.equal(+dateMath.startOf(date, 'hours'), +(new Date(2014,1,18,8,0,0,0)), 'startOf hours')
assert.equal(+dateMath.startOf(date, 'minutes'), +(new Date(2014,1,18,8,25,0,0)), 'startOf minutes')
assert.equal(+dateMath.startOf(date, 'seconds'), +(new Date(2014,1,18,8,25,30,0)), 'startOf seconds')
console.log(' passed')
console.log('---- end of ----------------------------')
assert.equal(+dateMath.endOf(date, 'year'), +(new Date(2014,11,31,23,59,59,999)), 'endOf year')
assert.equal(+dateMath.endOf(date, 'month'), +(new Date(2014,1,28,23,59,59,999)), 'endOf month')
assert.equal(+dateMath.endOf(date, 'day'), +(new Date(2014,1,18,23,59,59,999)), 'endOf day')
assert.equal(+dateMath.endOf(date, 'week'), +(new Date(2014,1,22,23,59,59,999)), 'endOf week')
assert.equal(+dateMath.endOf(date, 'hours'), +(new Date(2014,1,18,8,59,59,999)), 'endOf hours')
assert.equal(+dateMath.endOf(date, 'minutes'), +(new Date(2014,1,18,8,25,59,999)), 'endOf minutes')
assert.equal(+dateMath.endOf(date, 'seconds'), +(new Date(2014,1,18,8,25,30,999)), 'endOf seconds')
console.log(' passed')
console.log('---- Date Math ----------------------------')
assert.equal(+dateMath.add(date, 1, 'century'), +(new Date(2114, 1, 18, 8, 25, 30, 5)), 'add century')
assert.equal(+dateMath.add(date, 1, 'decade'), +(new Date(2024, 1, 18, 8, 25, 30, 5)), 'add decade')
assert.equal(+dateMath.add(date, 1, 'year'), +(new Date(2015, 1, 18, 8, 25, 30, 5)), 'add year')
assert.equal(+dateMath.add(dateLeapYear, 1, 'year'), +(new Date(2017, 0, 31, 8, 25, 30, 5)), 'add year to leap year')
assert.equal(+dateMath.add(date, 1, 'month'), +(new Date(2014, 2, 18, 8, 25, 30, 5)), 'add month')
assert.equal(+dateMath.add(dateLeapYear, 1, 'month'), +(new Date(2016, 1, 29, 8, 25, 30, 5)), 'add month on leap year')
assert.equal(+dateMath.add(date, 1, 'day'), +(new Date(2014, 1, 19, 8, 25, 30, 5)), 'add day')
assert.equal(+dateMath.add(dateLeapYear, 29, 'day'), +(new Date(2016, 1, 29, 8, 25, 30, 5)), 'add 29 days on leap year')
assert.equal(+dateMath.add(date, 1, 'week'), +(new Date(2014, 1, 25, 8, 25, 30, 5)), 'add week')
assert.equal(+dateMath.add(date, 1, 'hours'), +(new Date(2014, 1, 18, 9, 25, 30, 5)), 'add hours')
assert.equal(+dateMath.add(date, 24, 'hours'), +(new Date(2014, 1, 19, 8, 25, 30, 5)), 'add a day in hours')
assert.equal(+dateMath.add(dateLeapYear, 696, 'hours'), +(new Date(2016, 1, 29, 8, 25, 30, 5)), 'add 29 days in hours on leap year')
assert.equal(+dateMath.add(date, 1, 'minutes'), +(new Date(2014, 1, 18, 8, 26, 30, 5)), 'add minutes')
assert.equal(+dateMath.add(dateLeapYear, 41760, 'minutes'), +(new Date(2016, 1, 29, 8, 25, 30, 5)), 'add 29 days in minutes on leap year')
assert.equal(+dateMath.add(date, 1440, 'minutes'), +(new Date(2014, 1, 19, 8, 25, 30, 5)), 'add a day in minutes')
assert.equal(+dateMath.add(date, 1, 'seconds'), +(new Date(2014, 1, 18, 8, 25, 31, 5)), 'add seconds')
assert.equal(+dateMath.add(dateLeapYear, 2505600, 'seconds'), +(new Date(2016, 1, 29, 8, 25, 30, 5)), 'add 29 days in seconds on leap year')
assert.equal(+dateMath.add(date, 86400, 'seconds'), +(new Date(2014, 1, 19, 8, 25, 30, 5)), 'add a day in seconds')
assert.equal(+dateMath.add(date, 1, 'milliseconds'), +(new Date(2014, 1, 18, 8, 25, 30, 6)), 'add milliseconds')
assert.equal(+dateMath.add(date, 86400000, 'milliseconds'), +(new Date(2014, 1, 19, 8, 25, 30, 5)), 'add a day in milliseconds')
assert.equal(+dateMath.add(dateLeapYear, 2505600000, 'milliseconds'), +(new Date(2016, 1, 29, 8, 25, 30, 5)), 'add 29 days in milliseconds on leap year')
assert.equal(+dateMath.subtract(date, 24, 'month'), +dateMath.subtract(date, 2, 'year'), 'month rollover')
assert.equal(+dateMath.subtract(dateLeapYearOnFeb, 1, 'year'), +(new Date(2015, 1, 28, 8, 25, 30, 5)), 'subtract a leap year')
assert.equal(+dateMath.subtract(dateLeapYearOnFeb, 60, 'day'), +(new Date(2015, 11, 31, 8, 25, 30, 5)), 'subtract 60 days of a leap year')
assert.equal(+dateMath.max(date, new Date(2013, 0, 1, 0, 0, 0, 0)), +date, 'max')
assert.equal(+dateMath.min(date, new Date(2015, 0, 1, 0, 0, 0, 0)), +date, 'min')
assert.ok(dateMath.eq(date, new Date(2014,0,1,0,0,0,0), 'year'), 'eq year')
assert.ok(dateMath.neq(date, new Date(2013,0,1,0,0,0,0), 'year'), 'neq year')
assert.ok(dateMath.lte(date, new Date(2014,0,1,0,0,0,0), 'year'), 'lte year')
assert.ok(dateMath.lte(date, new Date(2015,0,1,0,0,0,0), 'year'), 'lte year')
assert.ok(dateMath.lt(date, new Date(2015,0,1,0,0,0,0), 'year'), 'lt year')
assert.ok(dateMath.gte(date, new Date(2014,0,1,0,0,0,0), 'year'), 'gte year')
assert.ok(dateMath.gte(date, new Date(2013,0,1,0,0,0,0), 'year'), 'gte year')
assert.ok(dateMath.gt(date, new Date(2013,0,1,0,0,0,0), 'year'), 'gt year')
assert.ok(dateMath.inRange(date, new Date(2013,0,1,0,0,0,0), new Date(2014,5,1,0,0,0,0)), 'inRange year')
assert.ok(!dateMath.inRange(new Date(2013,0,1,0,0,0,0), date, new Date(2014,5,1,0,0,0,0)), 'inRange year')
assert.ok(dateMath.inRange(date, null, new Date(2014,5,1,0,0,0,0)), 'inRange year')
assert.ok(dateMath.inRange(date, new Date(2013,0,1,0,0,0,0), null), 'inRange year')
assert.equal(dateMath.diff(date, date, 'milliseconds'), 0)
assert.equal(dateMath.diff(dateMath.subtract(date, 100, 'milliseconds'), date, 'milliseconds'), 100)
assert.equal(dateMath.diff(date, dateMath.subtract(date, 100, 'milliseconds'), 'milliseconds'), -100)
assert.equal(dateMath.diff(dateMath.subtract(date, 100, 'milliseconds'), date, 'seconds'), 0)
assert.equal(dateMath.diff(date, dateMath.subtract(date, 100, 'milliseconds'), 'seconds'), 0)
assert.equal(dateMath.diff(dateMath.subtract(date, 100, 'milliseconds'), date, 'seconds', true), 0.1)
assert.equal(dateMath.diff(date, dateMath.subtract(date, 100, 'milliseconds'), 'seconds', true), -0.1)
assert.equal(dateMath.diff(dateMath.subtract(date, 1000, 'milliseconds'), date, 'seconds'), 1)
assert.equal(dateMath.diff(dateMath.subtract(date, 12, 'minutes'), date, 'minutes'), 12)
assert.equal(dateMath.diff(dateMath.subtract(date, 2, 'hours'), date, 'minutes'), 120)
assert.equal(dateMath.diff(dateMath.subtract(date, 2, 'hours'), date, 'hours'), 2)
assert.equal(dateMath.diff(dateMath.subtract(date, 1, 'day'), date, 'day'), 1)
assert.equal(dateMath.diff(beforeDaylightSavingTime, afterDaylightSavingTime, 'day'), 1)
assert.equal(dateMath.diff(dateMath.subtract(date, 125, 'month'), date, 'month'), 125)
assert.equal(dateMath.diff(dateMath.subtract(date, 125, 'month'), date, 'year'), 10)
assert.equal(dateMath.diff(date, dateMath.subtract(date, 125, 'month'), 'year'), -10)
assert.equal(dateMath.diff(dateMath.subtract(date, 126, 'month'), date, 'year', true), 10.5)
assert.equal(dateMath.diff(date, dateMath.subtract(date, 126, 'month'), 'year', true), -10.5)
assert.equal(dateMath.diff(dateMath.subtract(date, 125, 'month'), date, 'decade'), 1)
assert.equal(dateMath.diff(dateMath.subtract(date, 250, 'month'), date, 'decade'), 2)
assert.equal(dateMath.diff(dateMath.subtract(date, 10, 'year'), date, 'century'), 0)
assert.equal(dateMath.diff(dateMath.subtract(date, 100, 'year'), date, 'century'), 1)
assert.equal(dateMath.diff(dateMath.subtract(date, 101, 'year'), date, 'century'), 1)
assert.equal(dateMath.diff(date, dateMath.subtract(date, 101, 'year'), 'century'), -1)
assert.equal(dateMath.diff(dateMath.subtract(date, 101, 'year'), date, 'century', true), 1.01)
assert.equal(dateMath.diff(dateMath.subtract(date, 201, 'year'), date, 'century'), 2)
assert.throws(function () {
dateMath.diff(dateMath.subtract(date, 201, 'year'), date, 'unknown');
}, /Invalid units: "unknown"/);
console.log(' passed')