(): UtcGets the current time using Date.now.
When to use
Use when synchronous wall-clock access outside an Effect program is
acceptable and testability through the Clock service is not needed.
Details
This is a synchronous version of now that directly uses Date.now()
instead of the Effect Clock service.
Example (Getting the current DateTime unsafely)
import { DateTime } from "effect"
const now = DateTime.nowUnsafe()
console.log(DateTime.formatIso(now))export const const nowUnsafe: LazyArg<Utc>Gets the current time using Date.now.
When to use
Use when synchronous wall-clock access outside an Effect program is
acceptable and testability through the Clock service is not needed.
Details
This is a synchronous version of now that directly uses Date.now()
instead of the Effect Clock service.
Example (Getting the current DateTime unsafely)
import { DateTime } from "effect"
const now = DateTime.nowUnsafe()
console.log(DateTime.formatIso(now))
nowUnsafe: type LazyArg<A> = () => AA zero-argument function that produces a value when invoked.
When to use
Use to type a lazy value provider that should not run until called.
Example (Creating a lazy argument)
import { Function } from "effect"
const constNull: Function.LazyArg<null> = Function.constant(null)
LazyArg<Utc> = import InternalInternal.const nowUnsafe: LazyArg<DateTime.Utc>nowUnsafe