Package: effect
Module: DateTime
Create a DateTime from supported input values.
When to use
Use when creating a DateTime from trusted input and construction failures
should throw an IllegalArgumentError instead of returning Option.none.
Details
DateTimeDate instance (invalid dates will throw an IllegalArgumentError)number of milliseconds since the Unix epochstring that can be parsed by Date.parseExample (Creating DateTime values unsafely)
import { DateTime } from "effect"
// from Date
const fromDate = DateTime.makeUnsafe(new Date("2024-01-01T12:00:00Z"))
console.log(DateTime.formatIso(fromDate)) // "2024-01-01T12:00:00.000Z"
// from parts
const fromParts = DateTime.makeUnsafe({ year: 2024 })
console.log(DateTime.formatIso(fromParts)) // "2024-01-01T00:00:00.000Z"
// from string
const fromString = DateTime.makeUnsafe("2024-01-01")
console.log(DateTime.formatIso(fromString)) // "2024-01-01T00:00:00.000Z"
Signature
declare const makeUnsafe: <A extends DateTime.Input>(input: A) => DateTime.PreserveZone<A>
Since v4.0.0