isPast
Check if a datetime is in the past
Returns true if the given datetime is in the past (before the current instant).
Signature
function isPast(
date: Temporal.Instant | Temporal.ZonedDateTime
): booleanParameters
| Parameter | Type | Description |
|---|---|---|
date | Temporal.Instant | Temporal.ZonedDateTime | The datetime to check |
Returns
true if the datetime is in the past, false otherwise.
Examples
import { isPast } from '@gobrand/tiempo';
const yesterday = Temporal.Now.zonedDateTimeISO().subtract({ days: 1 });
const tomorrow = Temporal.Now.zonedDateTimeISO().add({ days: 1 });
isPast(yesterday); // true
isPast(tomorrow); // falseWith Instant
const pastInstant = Temporal.Now.instant().subtract({ hours: 1 });
isPast(pastInstant); // true