15 lines
476 B
Plaintext
15 lines
476 B
Plaintext
"use strict";
|
|
const normalizeUnit = require("./normalizeUnit-Cn0hUyBC.js");
|
|
const endOf = require("./endOf.js");
|
|
const parse = require("./parse.js");
|
|
const startOf = require("./startOf.js");
|
|
function isSame(date, input, unit) {
|
|
unit = normalizeUnit.normalizeUnit(unit);
|
|
const inputMs = +parse(input);
|
|
if (!unit) {
|
|
return +date === inputMs;
|
|
}
|
|
return +startOf(new Date(date), unit) <= inputMs && inputMs <= +endOf(new Date(date), unit);
|
|
}
|
|
module.exports = isSame;
|