effect-io-ai

Package: effect
Module: SchemaTransformation

SchemaTransformation.durationFromMillis

Decodes a number of milliseconds into a Duration and encodes a Duration back to milliseconds.

When to use

Use when you need a schema transformation to decode timeouts, delays, elapsed intervals, or other duration values stored as millisecond counts.

Details

Decode creates a duration from the number, and encode returns the duration length in milliseconds.

Example (Converting milliseconds to a Duration)

import { Schema, SchemaTransformation } from "effect"

const schema = Schema.Number.pipe(
  Schema.decodeTo(Schema.Duration, SchemaTransformation.durationFromMillis)
)

See

Signature

declare const durationFromMillis: Transformation<Duration.Duration, number, never, never>

Source

Since v4.0.0