timepiece/node_modules/date-fns/differenceInMilliseconds.js

32 lines
1.0 KiB
JavaScript
Raw Normal View History

2024-05-14 14:54:12 +00:00
"use strict";
exports.differenceInMilliseconds = differenceInMilliseconds;
var _index = require("./toDate.js");
/**
* @name differenceInMilliseconds
* @category Millisecond Helpers
* @summary Get the number of milliseconds between the given dates.
*
* @description
* Get the number of milliseconds between the given dates.
*
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
*
* @param dateLeft - The later date
* @param dateRight - The earlier date
*
* @returns The number of milliseconds
*
* @example
* // How many milliseconds are between
* // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
* const result = differenceInMilliseconds(
* new Date(2014, 6, 2, 12, 30, 21, 700),
* new Date(2014, 6, 2, 12, 30, 20, 600)
* )
* //=> 1100
*/
function differenceInMilliseconds(dateLeft, dateRight) {
return +(0, _index.toDate)(dateLeft) - +(0, _index.toDate)(dateRight);
}