Scan your whole stack
From OX Research Newsroom
Are you using temporal-utils?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v1.0.5
temporal-utils was last scanned on 29 Nov 2026 at version 1.0.5. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 1.0.5 LATEST | 29 Nov 2026 | No rules fired |
| 1.0.4 | 4 Nov 2026 | No rules fired |
| 1.0.3 | 11 Sep 2026 | No rules fired |
| 1.0.2 | 13 Aug 2026 | Not shown |
Findings for v1.0.5. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 1.0.5; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
Small helpers for working with standard Temporal objects 🛠️
Most helpers preserve the input type. Passing a Temporal.PlainDateTime to startOfMonth returns a Temporal.PlainDateTime; passing a Temporal.ZonedDateTime returns a Temporal.ZonedDateTime.
npm install temporal-utils
Does not bundle a Temporal implementation. See Requirements.
Import helpers from the package root and pass any supported Temporal instance:
import { startOfMonth, diffDays } from 'temporal-utils'
// Pass a PlainDate, get a PlainDate back
startOfMonth(Temporal.PlainDate.from('2024-07-20')).toString()
// '2024-07-01'
// Pass a ZonedDateTime, get a ZonedDateTime back
startOfMonth(
Temporal.ZonedDateTime.from('2024-07-20T12:30[America/New_York]'),
).toString()
// '2024-07-01T00:00:00-04:00[America/New_York]'
diffDays(
Temporal.PlainDate.from('2024-07-01'),
Temporal.PlainDate.from('2024-07-20'),
)
// 19
temporal-utils does not bundle a Temporal implementation. It operates on any standard Temporal instances you pass in — whether from native Temporal, a global polyfill, or a local ponyfill import such as import { Temporal } from 'temporal-polyfill'.
The examples in this README assume a global Temporal, provided either by:
Native Temporal in browsers and runtimes that ship it.
A global polyfill, such as temporal-polyfill:
import 'temporal-polyfill/global'
withDayOfYearwithDayOfWeekwithWeekOfYeardiffYearsdiffMonthsdiffWeeksdiffDaysdiffHoursdiffMinutesdiffSecondsdiffMillisecondsdiffMicrosecondsdiffNanosecondsroundToYearroundToMonthroundToWeekroundToDayroundToHourroundToMinuteroundToSecondroundToMillisecondroundToMicrosecondstartOfYearstartOfMonthstartOfWeekstartOfDaystartOfHourstartOfMinutestartOfSecondstartOfMillisecondstartOfMicrosecondendOfYearendOfMonthendOfWeekendOfDayendOfHourendOfMinuteendOfSecondendOfMillisecondendOfMicrosecondRoundingModeRoundingMathOptionsThese helpers fill gaps where Temporal exposes calendar-derived fields such as
dayOfYear, dayOfWeek, and weekOfYear, but does not provide direct
with({ ... }) fields for replacing them.
All field replacement helpers:
Temporal.PlainDate, Temporal.PlainDateTime, or
Temporal.ZonedDateTime{ overflow: 'constrain' } or
{ overflow: 'reject' }'constrain'withDayOfYearSignature:
function withDayOfYear<
T extends Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime,
>(
date: T,
dayOfYear: number,
options?: Temporal.OverflowOptions,
): T
Returns the same calendar year with dayOfYear replaced. The time, time zone,
and calendar are preserved.
import { withDayOfYear } from 'temporal-utils'
const date = Temporal.PlainDate.from('2024-02-27')
withDayOfYear(date, 5).toString()
// '2024-01-05'
withDayOfYear(date, 500).toString()
// '2024-12-31'
withDayOfYear(date, 500, { overflow: 'reject' })
// RangeError
withDayOfWeekSignature:
function withDayOfWeek<
T extends Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime,
>(
date: T,
dayOfWeek: number,
options?: Temporal.OverflowOptions,
): T
Returns the same ISO week with dayOfWeek replaced. Temporal uses ISO weekday
numbers: Monday is 1 and Sunday is 7.
import { withDayOfWeek } from 'temporal-utils'
const date = Temporal.PlainDate.from('2024-02-27') // Tuesday
withDayOfWeek(date, 4).toString()
// '2024-02-29'
withDayOfWeek(date, 8).toString()
// '2024-03-03'
withWeekOfYearSignature:
function withWeekOfYear<
T extends Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime,
>(
date: T,
weekOfYear: number,
options?: Temporal.OverflowOptions,
): T
Returns the same ISO week-year with weekOfYear replaced, preserving the
current day of week. This helper is ISO-only and throws a RangeError for
calendars where Temporal does not expose ISO week fields.
import { withWeekOfYear } from 'temporal-utils'
const date = Temporal.PlainDate.from('2024-02-27') // Tuesday, week 9
withWeekOfYear(date, 27).toString()
// '2024-07-02'
withWeekOfYear(date.withCalendar('hebrew'), 27)
// RangeError
Single-unit difference helpers return a number for date0.until(date1). The
helpers are directional: reversing the arguments flips the sign (for variable-length
calendar units such as months or years, the magnitude can also differ slightly
depending on which endpoint anchors the calculation).
If no options are supplied, the result is the exact total in the requested unit.
Pass a RoundingMode string or a RoundingMathOptions object to request Temporal
rounding behavior for that unit.
import { diffDays, diffMonths } from 'temporal-utils'
const start = Temporal.PlainDate.from('2024-02-20')
const end = Temporal.PlainDate.from('2024-04-10')
diffMonths(start, end)
// approximately 1.677...
diffMonths(start, end, 'floor')
// 1
diffDays(start, end, { roundingMode: 'ceil', roundingIncrement: 7 })
// 56
Date and calendar unit helpers use relativeTo internally so totals account
for calendar units. For Temporal.ZonedDateTime, totals also account for
time-zone transitions. Time-unit helpers produce elapsed-time totals.
diffYearsSignature:
function diffYears(
date0: Temporal.PlainYearMonth | Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime,
date1: Temporal.PlainYearMonth | Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime,
options?: RoundingMode | RoundingMathOptions,
): number
Returns the difference in years. Supported input types are
Temporal.PlainYearMonth, Temporal.PlainDate, Temporal.PlainDateTime, and
Temporal.ZonedDateTime.
diffMonthsSignature:
function diffMonths(
date0: Temporal.PlainYearMonth | Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime,
date1: Temporal.PlainYearMonth | Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime,
options?: RoundingMode | RoundingMathOptions,
): number
Returns the difference in months. Supported input types are
Temporal.PlainYearMonth, Temporal.PlainDate, Temporal.PlainDateTime, and
Temporal.ZonedDateTime.
diffWeeksSignature:
function diffWeeks(
date0: Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime,
date1: Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime,
options?: RoundingMode | RoundingMathOptions,
): number
Returns the difference in weeks. Supported input types are Temporal.PlainDate,
Temporal.PlainDateTime, and Temporal.ZonedDateTime.
diffDaysSignature:
function diffDays(
date0: Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime,
date1: Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime,
options?: RoundingMode | RoundingMathOptions,
): number
Returns the difference in days. Supported input types are Temporal.PlainDate,
Temporal.PlainDateTime, and Temporal.ZonedDateTime.
diffHoursSignature:
function diffHours(
date0: Temporal.Instant | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime,
date1: Temporal.Instant | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime,
options?: RoundingMode | RoundingMathOptions,
): number
Returns the difference in hours. Supported input types are Temporal.Instant,
Temporal.PlainTime, Temporal.PlainDateTime, and Temporal.ZonedDateTime.
diffMinutesSignature:
function diffMinutes(
date0: Temporal.Instant | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime,
date1: Temporal.Instant | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime,
options?: RoundingMode | RoundingMathOptions,
): number
Returns the difference in minutes. Supported input types are Temporal.Instant,
Temporal.PlainTime, Temporal.PlainDateTime, and Temporal.ZonedDateTime.
diffSecondsSignature:
function diffSeconds(
date0: Temporal.Instant | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime,
date1: Temporal.Instant | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime,
options?: RoundingMode | RoundingMathOptions,
): number
Returns the difference in seconds. Supported input types are Temporal.Instant,
Temporal.PlainTime, Temporal.PlainDateTime, and Temporal.ZonedDateTime.
diffMillisecondsSignature:
function diffMilliseconds(
date0: Temporal.Instant | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime,
date1: Temporal.Instant | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime,
options?: RoundingMode | RoundingMathOptions,
): number
Returns the difference in milliseconds. Supported input types are
Temporal.Instant, Temporal.PlainTime, Temporal.PlainDateTime, and
Temporal.ZonedDateTime.
diffMicrosecondsSignature:
function diffMicroseconds(
date0: Temporal.Instant | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime,
date1: Temporal.Instant | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime,
options?: RoundingMode | RoundingMathOptions,
): number
Returns the difference in microseconds. Supported input types are
Temporal.Instant, Temporal.PlainTime, Temporal.PlainDateTime, and
Temporal.ZonedDateTime.
diffNanosecondsSignature:
function diffNanoseconds(
date0: Temporal.Instant | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime,
date1: Temporal.Instant | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime,
options?: RoundingMode | RoundingMathOptions,
): number
Returns the difference in nanoseconds. Supported input types are
Temporal.Instant, Temporal.PlainTime, Temporal.PlainDateTime, and
Temporal.ZonedDateTime.
Calendar rounding helpers return the closest start of the named unit. Temporal's built-in .round() stops at days (and PlainDate / PlainYearMonth have no .round()), so these helpers cover year, month, and week boundaries.
If options or options.roundingMode is omitted, roundingMode defaults to
'halfExpand'. Pass a RoundingMode string as shorthand for
{ roundingMode }.
RoundingMathOptions must not include smallestUnit; the helper name supplies
the unit. For the year, month, and week helpers, roundingIncrement must be
omitted or 1.
import { roundToMonth, roundToWeek, roundToYear } from 'temporal-utils'
const dateTime = Temporal.PlainDateTime.from('2024-07-20T12:30:00')
roundToYear(dateTime).toString()
// '2025-01-01T00:00:00'
roundToMonth(dateTime, 'floor').toString()
// '2024-07-01T00:00:00'
roundToWeek(dateTime, { roundingMode: 'floor' }).toString()
// '2024-07-15T00:00:00'
⚠️ The day and smaller roundTo* helpers are exported as codemod targets rather
than recommended hand-written API. In application code, prefer Temporal's built-in
.round() directly:
dateTime.round({ smallestUnit: 'day' })
time.round({ smallestUnit: 'minute', roundingMode: 'ceil' })
instant.round({ smallestUnit: 'second' })
roundToYearSignature:
function roundToYear<
T extends
| Temporal.PlainYearMonth
| Temporal.PlainDate
| Temporal.PlainDateTime
| Temporal.ZonedDateTime,
>(date: T, options?: RoundingMode | RoundingMathOptions): T
Rounds to the nearest year boundary. Supported input types are
Temporal.PlainYearMonth, Temporal.PlainDate, Temporal.PlainDateTime, and
Temporal.ZonedDateTime.
roundToMonthSignature:
function roundToMonth<
T extends Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime,
>(date: T, options?: RoundingMode | RoundingMathOptions): T
Rounds to the nearest month boundary. Supported input types are
Temporal.PlainDate, Temporal.PlainDateTime, and Temporal.ZonedDateTime.
roundToWeekSignature:
function roundToWeek<
T extends Temporal.PlainDate | Temporal.PlainDateTime | Temporal.ZonedDateTime,
>(date: T, options?: RoundingMode | RoundingMathOptions): T
Rounds to the nearest ISO week boundary. Supported input types are
Temporal.PlainDate, Temporal.PlainDateTime, and Temporal.ZonedDateTime.
roundToDaySignature:
function roundToDay<T extends Temporal.PlainDateTime | Temporal.ZonedDateTime>(
date: T,
options?: RoundingMode | RoundingMathOptions,
): T
Codemod target for rounding to the nearest day. Prefer
dateTime.round({ smallestUnit: 'day' }) in hand-written code.
roundToHourSignature:
function roundToHour<
T extends Temporal.Instant | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime,
>(date: T, options?: RoundingMode | RoundingMathOptions): T
Codemod target for rounding to the nearest hour. Prefer
value.round({ smallestUnit: 'hour' }) in hand-written code.
roundToMinuteSignature:
function roundToMinute<
T extends Temporal.Instant | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime,
>(date: T, options?: RoundingMode | RoundingMathOptions): T
Codemod target for rounding to the nearest minute. Prefer
value.round({ smallestUnit: 'minute' }) in hand-written code.
roundToSecondSignature:
function roundToSecond<
T extends Temporal.Instant | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime,
>(date: T, options?: RoundingMode | RoundingMathOptions): T
Codemod target for rounding to the nearest second. Prefer
value.round({ smallestUnit: 'second' }) in hand-written code.
roundToMillisecondSignature:
function roundToMillisecond<
T extends Temporal.Instant | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime,
>(date: T, options?: RoundingMode | RoundingMathOptions): T
Codemod target for rounding to the nearest millisecond. Prefer
value.round({ smallestUnit: 'millisecond' }) in hand-written code.
roundToMicrosecondSignature:
function roundToMicrosecond<
T extends Temporal.Instant | Temporal.PlainTime | Temporal.PlainDateTime | Temporal.ZonedDateTime,
>(date: T, options?: RoundingMode | RoundingMathOptions): T
Codemod target for rounding to the nearest microsecond. Prefer
value.round({ smallestUnit: 'microsecond' }) in hand-written code.
Start helpers truncate smaller fields to the beginning of the named unit.
startOfWeek uses ISO weeks, so the week starts on Monday.
For Temporal.ZonedDateTime, these helpers use Temporal's own field
replacement behavior. If local midnight is skipped by a time-zone transition,
Temporal resolves to the first real instant after the skipped wall time.
import { startOfMonth, startOfWeek } from 'temporal-utils'
const zdt = Temporal.ZonedDateTime.from('2024-07-20T12:30:00[America/New_York]')
startOfMonth(zdt).toString()
// '2024-07-01T00:00:00-04:00[America/New_York]'
startOfWeek(zdt).toString()
// '2024-07-15T00:00:00-04:00[America/New_York]'
startOfYearSignature:
function startOfYear<
T extends
| Temporal.PlainYearMonth
| Temporal.PlainDate
| Temporal.PlainDateTime
| Temporal.ZonedDateTime,
>(date: T): T Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.