effect-io-ai

Package: effect
Module: DateTime

DateTime.isPastUnsafe

Checks synchronously if a DateTime is in the past compared to the current time.

When to use

Use when checking whether a DateTime is in the past with a synchronous live-clock read and Clock-based testability is not needed.

Details

This is a synchronous version that uses Date.now() directly.

Example (Checking past DateTime values unsafely)

import { DateTime } from "effect"

const now = DateTime.nowUnsafe()
const pastDate = DateTime.subtract(now, { hours: 1 })

console.log(DateTime.isPastUnsafe(pastDate)) // true
console.log(DateTime.isPastUnsafe(now)) // false

Signature

declare const isPastUnsafe: (self: DateTime) => boolean

Source

Since v4.0.0