@steve31415/utilities
v0.1.1
Published
Shared utilities for Plasticine Way apps — natural-language time-spec parsing, plus a home for other small shared helpers.
Readme
@steve31415/utilities
Shared utilities for Plasticine Way apps. A home for small, broadly-useful helpers that would otherwise be copy-pasted between apps.
Currently provides natural-language time-spec parsing (extracted from Radar's
snooze entry): turn free text like 6PM, Wed, Thu 3PM, or 7/4 9AM into a
concrete epoch-ms instant (Pacific time, DST-correct), and format an instant back for
display.
API
import { resolveTimeSpec, formatTimeSpec } from '@steve31415/utilities';
resolveTimeSpec('Thu 3PM'); // → { at: <epoch ms> } (or { error: string })
resolveTimeSpec('6PM', Date.now()); // pass `now` to pin the clock (tests/determinism)
formatTimeSpec(1750000000000); // → "Thu Jun 25, 3:00 PM"Resolution rules:
- date + time (
Thu 3PM,7/4 9AM) → that date at that time - bare time (
6PM,noon) → next instance: today if still future, else tomorrow - date only (
Wed,tomorrow,7/4) → that date at midnight - weekday names always resolve to the next occurrence (never today)
- a time in the past, or unrecognized/empty input →
{ error }
Lower-level primitives parseDatePrefix, parseTimePrefix, and
pacificWallClockToEpochMs are also exported.
Publishing
Published via npm Trusted Publishing. Push a v* tag to trigger the GitHub Actions
workflow, which builds, tests, and publishes automatically.
# 1. Bump version in package.json
# 2. Commit the version bump
# 3. Tag and push:
git tag v<version>
git push && git push origin v<version>