registration

This commit is contained in:
User
2025-02-02 16:08:03 +03:00
parent 7f6495eb4d
commit 78afbaed71
6334 changed files with 196774 additions and 165754 deletions

View File

@@ -1,6 +1,8 @@
"use strict";
exports.lastDayOfDecade = lastDayOfDecade;
var _index = require("./toDate.js");
import { toDate } from "./toDate.js";
/**
* The {@link lastDayOfDecade} function options.
*/
/**
* @name lastDayOfDecade
@@ -10,9 +12,11 @@ var _index = require("./toDate.js");
* @description
* Return the last day of a decade for 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 DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows using extensions like [`UTCDate`](https://github.com/date-fns/utc).
* @typeParam ResultDate - The result `Date` type; inferred from arguments or specified by context.
*
* @param date - The original date
* @param options - The options
*
* @returns The last day of a decade
*
@@ -21,14 +25,14 @@ var _index = require("./toDate.js");
* const result = lastDayOfDecade(new Date(2012, 11, 21, 21, 12, 00))
* //=> Wed Dec 31 2019 00:00:00
*/
function lastDayOfDecade(date) {
// TODO: Switch to more technical definition in of decades that start with 1
// end with 0. I.e. 2001-2010 instead of current 2000-2009. It's a breaking
// change, so it can only be done in 4.0.
const _date = (0, _index.toDate)(date);
export function lastDayOfDecade(date, options) {
const _date = toDate(date, options?.in);
const year = _date.getFullYear();
const decade = 9 + Math.floor(year / 10) * 10;
_date.setFullYear(decade + 1, 0, 0);
_date.setHours(0, 0, 0, 0);
return _date;
return toDate(_date, options?.in);
}
// Fallback for modularized imports:
export default lastDayOfDecade;