@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
60 lines • 2.69 kB
TypeScript
import { type DateMode } from './types.ts';
/**
* The default style, carrying the clock an invocation renders by.
*
* @param env the command environment, read for `GIT_TEST_DATE_NOW` and `TZ`
*/
export declare function dateClock(env: Readonly<Record<string, string>> | null | undefined): DateMode;
/**
* Read a `--date` value.
*
* `auto:<anything>` is the default style, since it names the style for a
* terminal and mirage's output is never one. `local` alone is `default-local`.
* A value starting `format` takes `-local` and then must have its colon; any
* other must be a style name, with or without `-local`.
*
* @param value the value as typed
* @param clock the invocation's clock, from `dateClock`
*/
export declare function parseDateMode(value: string, clock: DateMode): DateMode;
/**
* An offset as git prints one, `%+05d` of `±HHMM`.
*
* @param offsetMinutes minutes east of UTC
*/
export declare function zoneText(offsetMinutes: number): string;
/** `1 day` or `2 days`, git's Q_ in the untranslated locale. */
export declare function plural(count: number, unit: string): string;
/**
* How long before `now` a moment was, in git's words.
*
* Seconds count exactly; every larger unit is the one below it rounded half up
* (minutes from seconds, hours from minutes, days from hours, then weeks,
* months and years from days), and the first unit whose count stays under its
* limit is the one shown: seconds under 90, minutes under 90, hours under 36,
* days under 14, weeks while under 70 days and months while under 365. Up to
* five years the months left over follow the years. Measured against git
* 2.50.1 and 2.47.3 at every second of the first two days and of every
* transition up to 40 years: 90 s is `2 minutes ago`, 89.5 minutes `2 hours
* ago`.
*
* @param timestamp the moment, in epoch seconds
* @param now the moment counted from
*/
export declare function relativeDate(timestamp: number, now: number): string;
/**
* A date as `--date` renders it.
*
* `default` is `Mon Jan 5 09:05:00 2026 +0000` (the day unpadded, no offset
* with `-local`), `iso` is `2026-01-05 09:05:00 +0000`, `iso-strict`
* `2026-01-05T09:05:00+00:00` with `Z` for a zero offset, `rfc`
* `Mon, 5 Jan 2026 09:05:00 +0000`, `short` the date alone, `raw` the instant
* and the shown offset, and `unix` and `relative` the instant whatever
* `-local` says.
*
* @param timestamp seconds since the epoch
* @param offsetMinutes the date's own offset, minutes east of UTC
* @param mode the style, with its clock and zone
*/
export declare function showDate(timestamp: number, offsetMinutes: number, mode: DateMode): string;
//# sourceMappingURL=dates.d.ts.map