New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

@autometa/datetime

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@autometa/datetime

Date and time utilities for Autometa tests

npmnpm
Version
1.0.0-rc.0
Version published
Weekly downloads
24
700%
Maintainers
1
Weekly downloads
 
Created
Source

@autometa/datetime

Utilities for creating deterministic dates and measuring time differences in Autometa tests. The package provides:

  • Dates – convenience shortcuts (yesterday, nextWeek, midnight, etc.), phrase parsing ("2 days from now") and explicit time offsets.
  • Dates.iso / Dates.fmt – ISO string or YYYY-MM-DD formatted variants of the same API surface.
  • Time.diff – helpers for calculating the difference between two dates in milliseconds, seconds, minutes, hours, days, or weeks.
import { Dates, Time } from "@autometa/datetime";

// Shortcut access
const tomorrow = Dates.tomorrow;
const nextFortnight = Dates.iso.nextFortnight;

// Phrase parsing & offsets
const launch = Dates.fromPhrase("3 weeks from now");
const reminder = Dates.make(-2, "days");

// Time differences
const diffInHours = Time.diff.hours(new Date(), reminder);

Custom clocks

For deterministic scenarios (e.g. unit tests) you can inject your own clock via createDates:

import { createDates } from "@autometa/datetime";

const fixed = new Date("2024-01-01T08:00:00Z");
const clock = { now: () => fixed };

const dates = createDates({ clock });
expect(dates.today.toISOString()).toBe("2024-01-01T08:00:00.000Z");

Migration notes

  • Singletons (Dates, Time) remain for convenience but now wrap factories so you can create isolated instances with custom clocks.
  • Phrase parsing errors throw AutomationError with actionable messaging.
  • All packages enforce >=90% cobertura across statements/branches/functions.

FAQs

Package last updated on 14 Jan 2026

Related posts