registration
This commit is contained in:
60
frontend/style/node_modules/date-fns/set.js
generated
vendored
60
frontend/style/node_modules/date-fns/set.js
generated
vendored
@@ -1,8 +1,10 @@
|
||||
"use strict";
|
||||
exports.set = set;
|
||||
var _index = require("./constructFrom.js");
|
||||
var _index2 = require("./setMonth.js");
|
||||
var _index3 = require("./toDate.js");
|
||||
import { constructFrom } from "./constructFrom.js";
|
||||
import { setMonth } from "./setMonth.js";
|
||||
import { toDate } from "./toDate.js";
|
||||
|
||||
/**
|
||||
* The {@link set} function options.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name set
|
||||
@@ -20,9 +22,11 @@ var _index3 = require("./toDate.js");
|
||||
* other `setX` functions that date-fns provides if you are concerned about the bundle size.
|
||||
*
|
||||
* @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).
|
||||
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
||||
*
|
||||
* @param date - The date to be changed
|
||||
* @param values - The date values to be set
|
||||
* @param options - The options
|
||||
*
|
||||
* @returns The new date with options set
|
||||
*
|
||||
@@ -36,42 +40,22 @@ var _index3 = require("./toDate.js");
|
||||
* const result = set(new Date(2014, 8, 1, 1, 23, 45), { hours: 12 })
|
||||
* //=> Mon Sep 01 2014 12:23:45
|
||||
*/
|
||||
|
||||
function set(date, values) {
|
||||
let _date = (0, _index3.toDate)(date);
|
||||
export function set(date, values, options) {
|
||||
let _date = toDate(date, options?.in);
|
||||
|
||||
// Check if date is Invalid Date because Date.prototype.setFullYear ignores the value of Invalid Date
|
||||
if (isNaN(+_date)) {
|
||||
return (0, _index.constructFrom)(date, NaN);
|
||||
}
|
||||
if (isNaN(+_date)) return constructFrom(options?.in || date, NaN);
|
||||
|
||||
if (values.year != null) {
|
||||
_date.setFullYear(values.year);
|
||||
}
|
||||
|
||||
if (values.month != null) {
|
||||
_date = (0, _index2.setMonth)(_date, values.month);
|
||||
}
|
||||
|
||||
if (values.date != null) {
|
||||
_date.setDate(values.date);
|
||||
}
|
||||
|
||||
if (values.hours != null) {
|
||||
_date.setHours(values.hours);
|
||||
}
|
||||
|
||||
if (values.minutes != null) {
|
||||
_date.setMinutes(values.minutes);
|
||||
}
|
||||
|
||||
if (values.seconds != null) {
|
||||
_date.setSeconds(values.seconds);
|
||||
}
|
||||
|
||||
if (values.milliseconds != null) {
|
||||
_date.setMilliseconds(values.milliseconds);
|
||||
}
|
||||
if (values.year != null) _date.setFullYear(values.year);
|
||||
if (values.month != null) _date = setMonth(_date, values.month);
|
||||
if (values.date != null) _date.setDate(values.date);
|
||||
if (values.hours != null) _date.setHours(values.hours);
|
||||
if (values.minutes != null) _date.setMinutes(values.minutes);
|
||||
if (values.seconds != null) _date.setSeconds(values.seconds);
|
||||
if (values.milliseconds != null) _date.setMilliseconds(values.milliseconds);
|
||||
|
||||
return _date;
|
||||
}
|
||||
|
||||
// Fallback for modularized imports:
|
||||
export default set;
|
||||
|
||||
Reference in New Issue
Block a user