Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

temporal-utils

Latest version: v1.0.5

Overview

Last scanned
29 Nov 2026
Published
29 Nov 2026
npm package Publisher: arshaw
795 Stars
35 Forks
4 Versions
13.4M Downloads
TypeScript Repo language

Scan summary

temporal-utils was last scanned on 29 Nov 2026 at version 1.0.5. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 4 versions; the latest was published on 29 Nov 2026.
  • Findings: No rules fired in version 1.0.5.
  • Downloads: 13,443,845 downloads.

Versions

4 versions published
Versions and the rules that fired in each
VersionPublishedStatus
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

No rules fired in 1.0.5

Findings

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.

README

The publisher’s own README, as collected from the registry.

temporal-utils

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.

Installation

npm install temporal-utils

Does not bundle a Temporal implementation. See Requirements.

Usage

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

Requirements

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'

Function Reference

  • Field Replacement
    • withDayOfYear
    • withDayOfWeek
    • withWeekOfYear
  • Difference Helpers
    • diffYears
    • diffMonths
    • diffWeeks
    • diffDays
    • diffHours
    • diffMinutes
    • diffSeconds
    • diffMilliseconds
    • diffMicroseconds
    • diffNanoseconds
  • Rounding Helpers
    • roundToYear
    • roundToMonth
    • roundToWeek
    • ⚠️ roundToDay
    • ⚠️ roundToHour
    • ⚠️ roundToMinute
    • ⚠️ roundToSecond
    • ⚠️ roundToMillisecond
    • ⚠️ roundToMicrosecond
  • Start Of Unit
    • startOfYear
    • startOfMonth
    • startOfWeek
    • startOfDay
    • startOfHour
    • startOfMinute
    • startOfSecond
    • startOfMillisecond
    • startOfMicrosecond
  • End Of Unit
    • endOfYear
    • endOfMonth
    • endOfWeek
    • endOfDay
    • endOfHour
    • endOfMinute
    • endOfSecond
    • endOfMillisecond
    • endOfMicrosecond
  • Shared Types
    • RoundingMode
    • RoundingMathOptions

Field Replacement

These 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:

  • accept Temporal.PlainDate, Temporal.PlainDateTime, or Temporal.ZonedDateTime
  • truncate numeric input toward zero before applying it
  • accept Temporal field overflow options: { overflow: 'constrain' } or { overflow: 'reject' }
  • default overflow behavior to 'constrain'
withDayOfYear

Signature:

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
withDayOfWeek

Signature:

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'
withWeekOfYear

Signature:

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

Difference Helpers

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.

diffYears

Signature:

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.

diffMonths

Signature:

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.

diffWeeks

Signature:

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.

diffDays

Signature:

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.

diffHours

Signature:

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.

diffMinutes

Signature:

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.

diffSeconds

Signature:

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.

diffMilliseconds

Signature:

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.

diffMicroseconds

Signature:

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.

diffNanoseconds

Signature:

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.

Rounding Helpers

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' })
roundToYear

Signature:

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.

roundToMonth

Signature:

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.

roundToWeek

Signature:

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.

⚠️ roundToDay

Signature:

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.

⚠️ roundToHour

Signature:

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.

⚠️ roundToMinute

Signature:

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.

⚠️ roundToSecond

Signature:

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.

⚠️ roundToMillisecond

Signature:

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.

⚠️ roundToMicrosecond

Signature:

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 Of Unit

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]'
startOfYear

Signature:

function startOfYear<
  T extends
    | Temporal.PlainYearMonth
    | Temporal.PlainDate
    | Temporal.PlainDateTime
    | Temporal.ZonedDateTime,
>(date: T): T

OX Radar and Response Center

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.

Where it’s listed

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).

  • npm temporal-utils

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

PolinRider Returns
Research

PolinRider Returns: Hijacked npm Packages Use Ethereum Blockchain to Conceal Malware Infrastructure

Cry2Wolf: How to Tell a Real Bug from a Nothingburger
AI & VibeSec

Cry2Wolf: Not Every Branded Bug Deserves a Fire Drill

CVE

Java4Shell (CVE-2026-114938): Easy to Crash, Hard to Exploit — Less Than 0.12% of JVMs Estimated at Risk of RCE

Frame 2085668439 (1)
Group 1261154229