Rocky_Mountain_Vending/.pnpm-store/v10/files/e8/10866a974c8d4bb9f6830b7a47f3a1c8276d0f4186d8eb3985dc042e285f0d06449261aef45b02f80228b76b5347b279e9fd80ae7fc462caa3b9e44c6bda33
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

43 lines
1.7 KiB
Text

import type { ConstructableDate, ContextFn, DateArg } from "./types.js";
/**
* @name constructFrom
* @category Generic Helpers
* @summary Constructs a date using the reference date and the value
*
* @description
* The function constructs a new date using the constructor from the reference
* date and the given value. It helps to build generic functions that accept
* date extensions.
*
* It defaults to `Date` if the passed reference date is a number or a string.
*
* Starting from v3.7.0, it allows to construct a date using `[Symbol.for("constructDateFrom")]`
* enabling to transfer extra properties from the reference date to the new date.
* It's useful for extensions like [`TZDate`](https://github.com/date-fns/tz)
* that accept a time zone as a constructor argument.
*
* @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).
*
* @param date - The reference date to take constructor from
* @param value - The value to create the date
*
* @returns Date initialized using the given date and value
*
* @example
* import { constructFrom } from "./constructFrom/date-fns";
*
* // A function that clones a date preserving the original type
* function cloneDate<DateType extends Date>(date: DateType): DateType {
* return constructFrom(
* date, // Use constructor from the given date
* date.getTime() // Use the date value to create a new date
* );
* }
*/
export declare function constructFrom<
DateType extends Date | ConstructableDate,
ResultDate extends Date = DateType,
>(
date: DateArg<DateType> | ContextFn<ResultDate> | undefined,
value: DateArg<Date> & {},
): ResultDate;