Package: effect
Module: DateTime
Creates a DateTime safely from supported input values.
Details
DateTimeDateReturns Some with the constructed DateTime when the input is valid, or
None when construction would fail, including invalid Date instances or
unparseable strings.
Example (Creating optional DateTime values)
import { DateTime } from "effect"
// from Date
const fromDate = DateTime.make(new Date("2024-01-01T12:00:00Z"))
console.log(fromDate._tag) // "Some"
// from parts
const fromParts = DateTime.make({ year: 2024 })
console.log(fromParts._tag) // "Some"
// from string
const fromString = DateTime.make("2024-01-01")
console.log(fromString._tag) // "Some"
const invalid = DateTime.make("not a date")
console.log(invalid._tag) // "None"
Signature
declare const make: <A extends DateTime.Input>(input: A) => Option.Option<DateTime.PreserveZone<A>>
Since v3.6.0