Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

constructFrom

import { constructFrom } from "https://esm.sh/v135/date-fns@3.6.0/index.d.mts";
@example
import { constructFrom } from 'date-fns'

// A function that clones a date preserving the original type
function cloneDate<DateType extends Date(date: DateType): DateType {
  return constructFrom(
    date, // Use contrustor from the given date
    date.getTime() // Use the date value to create a new date
  )
}
function constructFrom<DateType extends Date>(date: DateType | number | string, value: Date | number | string): DateType;
§
constructFrom<DateType extends Date>(date: DateType | number | string, value: Date | number | string): DateType
[src]

§Type Parameters

§
DateType extends Date
[src]

§Parameters

§
date: DateType | number | string
[src]
  • The reference date to take constructor from
§
value: Date | number | string
[src]
  • The value to create the date

§Return Type

§
DateType
[src]

Date initialized using the given date and value