Hyperlinkv0.8.0-beta.28

DateTime

DateTime.isPastUnsafeconsteffect/DateTime.ts:1526
(self: DateTime): boolean

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
comparisons
export const isPastUnsafe: (self: DateTime) => boolean = Internal.isPastUnsafe