tiempo

endOfYear

Get the last boundary of the year

Returns the last boundary of the year. PlainDate inputs stay in calendar space and return the last date of the year; providing a timezone returns a ZonedDateTime at the last moment of that date.

Signature

function endOfYear(
  input: Temporal.Instant | Temporal.ZonedDateTime
): Temporal.ZonedDateTime

function endOfYear(input: Temporal.PlainDate): Temporal.PlainDate

function endOfYear(
  input: Temporal.PlainDate,
  timezone: Timezone
): Temporal.ZonedDateTime

Parameters

ParameterTypeDescription
inputTemporal.Instant | Temporal.ZonedDateTime | Temporal.PlainDateThe date or datetime to get the end of year for
timezoneTimezoneRequired only when converting a PlainDate boundary to a ZonedDateTime

Returns

A Temporal.PlainDate for calendar-only input, or a Temporal.ZonedDateTime at the last moment of the final day for datetime input or an explicit timezone.

Examples

import { endOfYear } from '@gobrand/tiempo';

const instant = Temporal.Instant.from('2025-06-15T12:00:00Z');
endOfYear(instant);
// 2025-12-31T23:59:59.999999999Z[UTC]

const zoned = Temporal.ZonedDateTime.from('2025-06-15T15:30:00-05:00[America/New_York]');
endOfYear(zoned);
// 2025-12-31T23:59:59.999999999-05:00[America/New_York]

const date = Temporal.PlainDate.from('2025-06-15');
endOfYear(date);
// 2025-12-31

endOfYear(date, 'UTC');
// 2025-12-31T23:59:59.999999999Z[UTC]

On this page