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,4 +1,6 @@
import type {
ContextOptions,
DateArg,
NearestHours,
NearestToUnitOptions,
RoundingOptions,
@@ -6,9 +8,10 @@ import type {
/**
* The {@link roundToNearestHours} function options.
*/
export interface RoundToNearestHoursOptions
export interface RoundToNearestHoursOptions<DateType extends Date = Date>
extends NearestToUnitOptions<NearestHours>,
RoundingOptions {}
RoundingOptions,
ContextOptions<DateType> {}
/**
* @name roundToNearestHours
* @category Hour Helpers
@@ -19,6 +22,7 @@ export interface RoundToNearestHoursOptions
* Rounds up when the given date is exactly between the nearest round hours.
*
* @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 round
* @param options - An object with options.
@@ -34,13 +38,13 @@ export interface RoundToNearestHoursOptions
* // Round 10 July 2014 12:34:56 to nearest half hour:
* const result = roundToNearestHours(new Date(2014, 6, 10, 12, 34, 56), { nearestTo: 6 })
* //=> Thu Jul 10 2014 12:00:00
*
* @example
* // Round 10 July 2014 12:34:56 to nearest half hour:
* const result = roundToNearestHours(new Date(2014, 6, 10, 12, 34, 56), { nearestTo: 8 })
* //=> Thu Jul 10 2014 16:00:00
* @example
*
* @example
* // Floor (rounds down) 10 July 2014 12:34:56 to nearest hour:
* const result = roundToNearestHours(new Date(2014, 6, 10, 1, 23, 45), { roundingMethod: 'ceil' })
* //=> Thu Jul 10 2014 02:00:00
@@ -50,7 +54,10 @@ export interface RoundToNearestHoursOptions
* const result = roundToNearestHours(new Date(2014, 6, 10, 12, 34, 56), { roundingMethod: 'floor', nearestTo: 8 })
* //=> Thu Jul 10 2014 08:00:00
*/
export declare function roundToNearestHours<DateType extends Date>(
date: DateType | number | string,
options?: RoundToNearestHoursOptions,
): Date;
export declare function roundToNearestHours<
DateType extends Date,
ResultDate extends Date = DateType,
>(
date: DateArg<DateType>,
options?: RoundToNearestHoursOptions<ResultDate>,
): ResultDate;