registration
This commit is contained in:
23
frontend/style/node_modules/date-fns/addMonths.js
generated
vendored
23
frontend/style/node_modules/date-fns/addMonths.js
generated
vendored
@@ -1,7 +1,9 @@
|
||||
"use strict";
|
||||
exports.addMonths = addMonths;
|
||||
var _index = require("./toDate.js");
|
||||
var _index2 = require("./constructFrom.js");
|
||||
import { constructFrom } from "./constructFrom.js";
|
||||
import { toDate } from "./toDate.js";
|
||||
|
||||
/**
|
||||
* The {@link addMonths} function options.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name addMonths
|
||||
@@ -12,9 +14,11 @@ var _index2 = require("./constructFrom.js");
|
||||
* Add the specified number of months to the given date.
|
||||
*
|
||||
* @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 amount - The amount of months to be added.
|
||||
* @param options - The options object
|
||||
*
|
||||
* @returns The new date with the months added
|
||||
*
|
||||
@@ -27,9 +31,9 @@ var _index2 = require("./constructFrom.js");
|
||||
* const result = addMonths(new Date(2023, 0, 30), 1)
|
||||
* //=> Tue Feb 28 2023 00:00:00
|
||||
*/
|
||||
function addMonths(date, amount) {
|
||||
const _date = (0, _index.toDate)(date);
|
||||
if (isNaN(amount)) return (0, _index2.constructFrom)(date, NaN);
|
||||
export function addMonths(date, amount, options) {
|
||||
const _date = toDate(date, options?.in);
|
||||
if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
|
||||
if (!amount) {
|
||||
// If 0 months, no-op to avoid changing times in the hour before end of DST
|
||||
return _date;
|
||||
@@ -44,7 +48,7 @@ function addMonths(date, amount) {
|
||||
// we'll default to the end of the desired month by adding 1 to the desired
|
||||
// month and using a date of 0 to back up one day to the end of the desired
|
||||
// month.
|
||||
const endOfDesiredMonth = (0, _index2.constructFrom)(date, _date.getTime());
|
||||
const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
|
||||
endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
|
||||
const daysInMonth = endOfDesiredMonth.getDate();
|
||||
if (dayOfMonth >= daysInMonth) {
|
||||
@@ -67,3 +71,6 @@ function addMonths(date, amount) {
|
||||
return _date;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback for modularized imports:
|
||||
export default addMonths;
|
||||
|
||||
Reference in New Issue
Block a user