@autometa/datetime 0.1.16 → 1.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/dates/date-factory.ts","../src/dates/clock.ts","../src/dates/time-units.ts","../src/shared/phrases.ts","../src/dates/formatted-date-factory.ts","../src/dates/iso-date-factory.ts","../src/dates/object.ts","../src/time/time-diff.ts","../src/time/time.ts"],"names":["AutomationError"],"mappings":";AAAA,SAAS,mBAAAA,wBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACFA,IAAM,cAAqB;AAAA,EAChC,KAAK,MAAM,oBAAI,KAAK;AACtB;AAEO,SAAS,UAAU,MAAkB;AAC1C,SAAO,IAAI,KAAK,KAAK,QAAQ,CAAC;AAChC;;;ACVA,SAAS,uBAAuB;AAiBhC,IAAM,eAAmD;AAAA,EACvD,aAAa,EAAE,MAAM,gBAAgB,OAAO,EAAE;AAAA,EAC9C,cAAc,EAAE,MAAM,gBAAgB,OAAO,EAAE;AAAA,EAC/C,IAAI,EAAE,MAAM,gBAAgB,OAAO,EAAE;AAAA,EACrC,QAAQ,EAAE,MAAM,WAAW,OAAO,EAAE;AAAA,EACpC,SAAS,EAAE,MAAM,WAAW,OAAO,EAAE;AAAA,EACrC,KAAK,EAAE,MAAM,WAAW,OAAO,EAAE;AAAA,EACjC,MAAM,EAAE,MAAM,WAAW,OAAO,EAAE;AAAA,EAClC,QAAQ,EAAE,MAAM,WAAW,OAAO,EAAE;AAAA,EACpC,SAAS,EAAE,MAAM,WAAW,OAAO,EAAE;AAAA,EACrC,KAAK,EAAE,MAAM,WAAW,OAAO,EAAE;AAAA,EACjC,MAAM,EAAE,MAAM,WAAW,OAAO,EAAE;AAAA,EAClC,MAAM,EAAE,MAAM,SAAS,OAAO,EAAE;AAAA,EAChC,OAAO,EAAE,MAAM,SAAS,OAAO,EAAE;A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A,KAAK,OAAa,KAAmB;AACnC,WAAO,KAAK,OAAO,OAAO,GAAG,IAAI;AAAA,EACnC;AAAA,EAEA,MAAM,OAAa,KAAmB;AACpC,WAAO,KAAK,OAAO,OAAO,GAAG,IAAI;AAAA,EACnC;AAAA,EAEA,MAAM,OAAa,KAAmB;AACpC,WAAO,KAAK,OAAO,OAAO,GAAG,IAAI;AAAA,EACnC;AAAA,EAEA,WAAW,QAA6B;AACtC,QAAI,OAAO,WAAW,UAAU;AAC9B,YAAM,IAAIA;AAAA,QACR,mDAAmD,OAAO,MAAM;AAAA,MAClE;AAAA,IACF;AAEF,UAAM,MAAM,eAAe,MAAM;AAC/B,QAAI,CAAC,KAAK,UAAU,GAAG,GAAG;AACxB,YAAM,IAAIA;AAAA,QACR,0BAA0B,MAAM,sBAAsB,KAAK,iBAAiB,EAAE,KAAK,IAAI,CAAC;AAAA,MAC1F;AAAA,IACF;AAEF,cAAU,MAAM,KAAmB,qBAAqB;AACxD,UAAM,SAAS,KAAK,GAAiB;AACnC,QAAI,OAAO,WAAW,YAAY;AAChC,YAAM,IAAIA,iBAAgB,gBAAgB,GAAG,oBAAoB;AAAA,IACnE;AACA,WAAQ,OAAsB,KAAK,IAAI;AAAA,EACzC;AAAA,EAEQ,UAAU,MAAuB;AACvC,WAAO,kBAAkB,SAAS,IAAkB;AAAA,EACtD;AAAA,EAEQ,mBAAiC;AACvC,WAAO,CAAC,GAAG,iBAAiB;AAAA,EAC9B;AACF;;;ACrEA,IAAM,aAAN,MAAwC;AAAA,EAGtC,YAAY,MAAgB;AAC1B,SAAK,OAAO;AAAA,EACd;AACF;AAEO,SAAS,aAA0B;AACxC,SAAO,IAAI,WAAW,IAAI,SAAS,CAAC;AACtC;AAEO,IAAM,OAAO,WAAW","sourcesContent":["import { AutomationError } from \"@autometa/errors\";\nimport {\n isValidDate,\n isValidISODateString,\n isValidTime,\n isValidYearMonth,\n} from \"iso-datestring-validator\";\nimport type { Clock } from \"./clock.js\";\nimport { cloneDate, systemClock } from \"./clock.js\";\nimport {\n resolveTimeUnit,\n type StandardTimeUnit,\n} from \"./time-units.js\";\nimport { normalizeToken, toCamelKey } from \"../shared/phrases.js\";\n\nexport type DateShortcut =\n | \"now\"\n | \"beforeYesterday\"\n | \"yesterday\"\n | \"today\"\n | \"tomorrow\"\n | \"afterTomorrow\"\n | \"midnight\"\n | \"lastWeek\"\n | \"nextWeek\"\n | \"lastFortnight\"\n | \"nextFortnight\";\n\nconst SHORTCUT_LOOKUP = new Set<DateShortcut>([\n \"now\",\n \"beforeYesterday\",\n \"yesterday\",\n \"today\",\n \"tomorrow\",\n \"afterTomorrow\",\n \"midnight\",\n \"lastWeek\",\n \"nextWeek\",\n \"lastFortnight\",\n \"nextFortnight\",\n]);\n\nexport interface DateFactoryOptions {\n clock?: Clock;\n}\n\ninterface RelativePhraseMatch {\n offset: number;\n unit: StandardTimeUnit;\n}\n\nconst FUTURE_PATTERN = /^(\\d+)\\s+([A-Za-z\\s]+?)\\s+from\\s+now$/i;\nconst PAST_PATTERN = /^(\\d+)\\s+([A-Za-z\\s]+?)\\s+ago$/i;\n\nfunction invalidDate(): Date {\n return new Date(Number.NaN);\n}\n\nfunction isDateShortcut(value: string): value is DateShortcut {\n return SHORTCUT_LOOKUP.has(value as DateShortcut);\n}\n\nexport class DateFactory {\n private readonly clock: Clock;\n\n constructor(options: DateFactoryOptions = {}) {\n this.clock = options.clock ?? systemClock;\n }\n\n find(shortcut: DateShortcut): Date {\n switch (shortcut) {\n case \"now\":\n return this.currentDate();\n case \"beforeYesterday\":\n return this.make(-2, \"days\");\n case \"yesterday\":\n return this.make(-1, \"days\");\n case \"today\":\n return this.make(0, \"days\");\n case \"tomorrow\":\n return this.make(1, \"days\");\n case \"afterTomorrow\":\n return this.make(2, \"days\");\n case \"midnight\":\n return this.midnight();\n case \"lastWeek\":\n return this.make(-1, \"weeks\");\n case \"nextWeek\":\n return this.make(1, \"weeks\");\n case \"lastFortnight\":\n return this.make(-14, \"days\");\n case \"nextFortnight\":\n return this.make(14, \"days\");\n default:\n throw new AutomationError(\n `Unsupported date shortcut '${shortcut}'.`\n );\n }\n }\n\n fromPhraseSafe(phrase: unknown): Date {\n if (typeof phrase !== \"string\") {\n return invalidDate();\n }\n\n const trimmed = phrase.trim();\n if (trimmed.length === 0) {\n return invalidDate();\n }\n\n const shortcutCandidate = toCamelKey(trimmed);\n if (isDateShortcut(shortcutCandidate)) {\n return this.find(shortcutCandidate);\n }\n\n const relative = this.extractRelative(trimmed);\n if (relative) {\n return this.make(relative.offset, relative.unit);\n }\n\n if (this.isDateLike(trimmed)) {\n return this.parseDate(trimmed);\n }\n\n return invalidDate();\n }\n\n fromPhrase(phrase: unknown): Date {\n const result = this.fromPhraseSafe(phrase);\n if (Number.isNaN(result.getTime())) {\n throw new AutomationError(\n `Could not parse date from phrase '${String(phrase)}'. ` +\n `Valid shortcuts are: ${[...SHORTCUT_LOOKUP].join(\", \")}.`\n );\n }\n return result;\n }\n\n make(timeOffset: number, timeUnit: string | StandardTimeUnit): Date {\n if (!Number.isFinite(timeOffset)) {\n throw new AutomationError(\n `Time offset must be finite. Received '${timeOffset}'.`\n );\n }\n\n const { unit, scale } = resolveTimeUnit(String(timeUnit));\n const offset = timeOffset * scale;\n const date = this.currentDate();\n\n switch (unit) {\n case \"years\":\n date.setFullYear(date.getFullYear() + offset);\n break;\n case \"months\":\n date.setMonth(date.getMonth() + offset);\n break;\n case \"weeks\":\n date.setDate(date.getDate() + offset * 7);\n break;\n case \"days\":\n date.setDate(date.getDate() + offset);\n break;\n case \"hours\":\n date.setHours(date.getHours() + offset);\n break;\n case \"minutes\":\n date.setMinutes(date.getMinutes() + offset);\n break;\n case \"seconds\":\n date.setSeconds(date.getSeconds() + offset);\n break;\n case \"milliseconds\":\n date.setMilliseconds(date.getMilliseconds() + offset);\n break;\n default:\n throw new AutomationError(`Unsupported time unit '${unit}'.`);\n }\n\n return date;\n }\n\n private currentDate(): Date {\n return cloneDate(this.clock.now());\n }\n\n private midnight(): Date {\n const date = this.currentDate();\n date.setUTCDate(date.getUTCDate() + 1);\n date.setUTCHours(0, 0, 0, 0);\n return date;\n }\n\n private parseDate(value: string): Date {\n const parsed = new Date(value);\n if (!Number.isNaN(parsed.getTime())) {\n return parsed;\n }\n return new Date(Date.parse(value));\n }\n\n private isDateLike(value: string): boolean {\n if (!Number.isNaN(new Date(value).getTime())) {\n return true;\n }\n return (\n isValidDate(value) ||\n isValidISODateString(value) ||\n isValidTime(value) ||\n isValidYearMonth(value)\n );\n }\n\n private extractRelative(phrase: string): RelativePhraseMatch | undefined {\n const futureMatch = FUTURE_PATTERN.exec(phrase);\n if (futureMatch) {\n return this.buildRelativeMatch(futureMatch, 1);\n }\n\n const pastMatch = PAST_PATTERN.exec(phrase);\n if (pastMatch) {\n return this.buildRelativeMatch(pastMatch, -1);\n }\n\n return undefined;\n }\n\n private buildRelativeMatch(\n match: RegExpExecArray,\n direction: 1 | -1\n ): RelativePhraseMatch | undefined {\n const value = match[1];\n const unit = match[2];\n if (!value || !unit) {\n return undefined;\n }\n\n const magnitude = Number.parseInt(value, 10);\n if (!Number.isFinite(magnitude)) {\n return undefined;\n }\n\n const convertedUnit = normalizeToken(unit);\n const { unit: normalisedUnit, scale } = resolveTimeUnit(convertedUnit);\n const offset = magnitude * scale * direction;\n return {\n offset,\n unit: normalisedUnit,\n };\n }\n}\n","export interface Clock {\n now(): Date;\n}\n\nexport const systemClock: Clock = {\n now: () => new Date(),\n};\n\nexport function cloneDate(date: Date): Date {\n return new Date(date.getTime());\n}\n","import { AutomationError } from \"@autometa/errors\";\n\nexport type StandardTimeUnit =\n | \"milliseconds\"\n | \"seconds\"\n | \"minutes\"\n | \"hours\"\n | \"days\"\n | \"weeks\"\n | \"months\"\n | \"years\";\n\nexport interface NormalisedTimeUnit {\n unit: StandardTimeUnit;\n scale: number;\n}\n\nconst UNIT_ALIASES: Record<string, NormalisedTimeUnit> = {\n millisecond: { unit: \"milliseconds\", scale: 1 },\n milliseconds: { unit: \"milliseconds\", scale: 1 },\n ms: { unit: \"milliseconds\", scale: 1 },\n second: { unit: \"seconds\", scale: 1 },\n seconds: { unit: \"seconds\", scale: 1 },\n sec: { unit: \"seconds\", scale: 1 },\n secs: { unit: \"seconds\", scale: 1 },\n minute: { unit: \"minutes\", scale: 1 },\n minutes: { unit: \"minutes\", scale: 1 },\n min: { unit: \"minutes\", scale: 1 },\n mins: { unit: \"minutes\", scale: 1 },\n hour: { unit: \"hours\", scale: 1 },\n hours: { unit: \"hours\", scale: 1 },\n hr: { unit: \"hours\", scale: 1 },\n hrs: { unit: \"hours\", scale: 1 },\n day: { unit: \"days\", scale: 1 },\n days: { unit: \"days\", scale: 1 },\n week: { unit: \"weeks\", scale: 1 },\n weeks: { unit: \"weeks\", scale: 1 },\n fortnight: { unit: \"days\", scale: 14 },\n fortnights: { unit: \"days\", scale: 14 },\n month: { unit: \"months\", scale: 1 },\n months: { unit: \"months\", scale: 1 },\n year: { unit: \"years\", scale: 1 },\n years: { unit: \"years\", scale: 1 },\n};\n\nexport function resolveTimeUnit(input: string): NormalisedTimeUnit {\n const key = input.trim().toLowerCase();\n const resolved = UNIT_ALIASES[key];\n if (!resolved) {\n throw new AutomationError(\n `Unsupported time unit '${input}'. Expected one of ${Object.keys(UNIT_ALIASES)\n .sort()\n .join(\", \")}.`\n );\n }\n return resolved;\n}\n","const SEPARATORS = /[\\s_-]+/g;\n\nfunction capitalize(word: string): string {\n return word.charAt(0).toUpperCase() + word.slice(1);\n}\n\nfunction splitWords(phrase: string): string[] {\n return phrase\n .trim()\n .split(SEPARATORS)\n .filter(Boolean)\n .map((word) => word.toLowerCase());\n}\n\nexport function toCamelKey(phrase: string): string {\n const words = splitWords(phrase);\n if (words.length === 0) {\n return \"\";\n }\n const [first, ...rest] = words;\n return first + rest.map(capitalize).join(\"\");\n}\n\nexport function normalizeToken(phrase: string): string {\n return splitWords(phrase).join(\"\");\n}\n","import type { DateFactory, DateShortcut } from \"./date-factory.js\";\nimport type { StandardTimeUnit } from \"./time-units.js\";\n\nexport interface FormattedDateFactoryOptions {\n formatter?: (date: Date) => string;\n}\n\nexport class FormattedDateFactory {\n private readonly format: (date: Date) => string;\n\n constructor(\n private readonly dateFactory: DateFactory,\n options: FormattedDateFactoryOptions = {}\n ) {\n this.format =\n options.formatter ?? ((date) => date.toISOString().substring(0, 10));\n }\n\n make(offset: number, unit: StandardTimeUnit | string): string {\n return this.format(this.dateFactory.make(offset, unit));\n }\n\n fromPhrase(phrase: unknown): string {\n return this.format(this.dateFactory.fromPhrase(phrase));\n }\n\n get beforeYesterday(): string {\n return this.fromShortcut(\"beforeYesterday\");\n }\n\n get yesterday(): string {\n return this.fromShortcut(\"yesterday\");\n }\n\n get today(): string {\n return this.fromShortcut(\"today\");\n }\n\n get tomorrow(): string {\n return this.fromShortcut(\"tomorrow\");\n }\n\n get afterTomorrow(): string {\n return this.fromShortcut(\"afterTomorrow\");\n }\n\n get midnight(): string {\n return this.fromShortcut(\"midnight\");\n }\n\n get lastWeek(): string {\n return this.fromShortcut(\"lastWeek\");\n }\n\n get nextWeek(): string {\n return this.fromShortcut(\"nextWeek\");\n }\n\n get lastFortnight(): string {\n return this.fromShortcut(\"lastFortnight\");\n }\n\n get nextFortnight(): string {\n return this.fromShortcut(\"nextFortnight\");\n }\n\n private fromShortcut(shortcut: DateShortcut): string {\n return this.format(this.dateFactory.find(shortcut));\n }\n}\n","import type { DateFactory, DateShortcut } from \"./date-factory.js\";\nimport type { StandardTimeUnit } from \"./time-units.js\";\n\nexport interface IsoDateFactoryOptions {\n serializer?: (date: Date) => string;\n}\n\nexport class IsoDateFactory {\n private readonly serialise: (date: Date) => string;\n\n constructor(\n private readonly dateFactory: DateFactory,\n options: IsoDateFactoryOptions = {}\n ) {\n this.serialise = options.serializer ?? ((date) => date.toISOString());\n }\n\n make(offset: number, unit: StandardTimeUnit | string): string {\n return this.serialise(this.dateFactory.make(offset, unit));\n }\n\n fromPhrase(phrase: unknown): string {\n return this.serialise(this.dateFactory.fromPhrase(phrase));\n }\n\n get beforeYesterday(): string {\n return this.fromShortcut(\"beforeYesterday\");\n }\n\n get yesterday(): string {\n return this.fromShortcut(\"yesterday\");\n }\n\n get today(): string {\n return this.fromShortcut(\"today\");\n }\n\n get tomorrow(): string {\n return this.fromShortcut(\"tomorrow\");\n }\n\n get afterTomorrow(): string {\n return this.fromShortcut(\"afterTomorrow\");\n }\n\n get midnight(): string {\n return this.fromShortcut(\"midnight\");\n }\n\n get lastWeek(): string {\n return this.fromShortcut(\"lastWeek\");\n }\n\n get nextWeek(): string {\n return this.fromShortcut(\"nextWeek\");\n }\n\n get lastFortnight(): string {\n return this.fromShortcut(\"lastFortnight\");\n }\n\n get nextFortnight(): string {\n return this.fromShortcut(\"nextFortnight\");\n }\n\n private fromShortcut(shortcut: DateShortcut): string {\n return this.serialise(this.dateFactory.find(shortcut));\n }\n}\n","import { DateFactory, type DateFactoryOptions, type DateShortcut } from \"./date-factory.js\";\nimport { FormattedDateFactory } from \"./formatted-date-factory.js\";\nimport { IsoDateFactory } from \"./iso-date-factory.js\";\nimport type { StandardTimeUnit } from \"./time-units.js\";\n\nexport interface DatesOptions extends DateFactoryOptions {\n factory?: DateFactory;\n}\n\nexport interface DatesObject {\n readonly iso: IsoDateFactory;\n readonly fmt: FormattedDateFactory;\n readonly now: Date;\n readonly beforeYesterday: Date;\n readonly yesterday: Date;\n readonly today: Date;\n readonly tomorrow: Date;\n readonly afterTomorrow: Date;\n readonly midnight: Date;\n readonly lastWeek: Date;\n readonly nextWeek: Date;\n readonly lastFortnight: Date;\n readonly nextFortnight: Date;\n fromPhrase(phrase: unknown): Date;\n fromPhraseSafe(phrase: unknown): Date;\n make(offset: number, unit: StandardTimeUnit | string): Date;\n}\n\nclass DatesFacade implements DatesObject {\n readonly iso: IsoDateFactory;\n readonly fmt: FormattedDateFactory;\n\n constructor(private readonly factory: DateFactory) {\n this.iso = new IsoDateFactory(factory);\n this.fmt = new FormattedDateFactory(factory);\n }\n\n get now(): Date {\n return this.fromShortcut(\"now\");\n }\n\n get beforeYesterday(): Date {\n return this.fromShortcut(\"beforeYesterday\");\n }\n\n get yesterday(): Date {\n return this.fromShortcut(\"yesterday\");\n }\n\n get today(): Date {\n return this.fromShortcut(\"today\");\n }\n\n get tomorrow(): Date {\n return this.fromShortcut(\"tomorrow\");\n }\n\n get afterTomorrow(): Date {\n return this.fromShortcut(\"afterTomorrow\");\n }\n\n get midnight(): Date {\n return this.fromShortcut(\"midnight\");\n }\n\n get lastWeek(): Date {\n return this.fromShortcut(\"lastWeek\");\n }\n\n get nextWeek(): Date {\n return this.fromShortcut(\"nextWeek\");\n }\n\n get lastFortnight(): Date {\n return this.fromShortcut(\"lastFortnight\");\n }\n\n get nextFortnight(): Date {\n return this.fromShortcut(\"nextFortnight\");\n }\n\n fromPhrase(phrase: unknown): Date {\n return this.factory.fromPhrase(phrase);\n }\n\n fromPhraseSafe(phrase: unknown): Date {\n return this.factory.fromPhraseSafe(phrase);\n }\n\n make(offset: number, unit: StandardTimeUnit | string): Date {\n return this.factory.make(offset, unit);\n }\n\n private fromShortcut(shortcut: DateShortcut): Date {\n return this.factory.find(shortcut);\n }\n}\n\nexport function createDates(options: DatesOptions = {}): DatesObject {\n const factory = options.factory ?? new DateFactory(options);\n return new DatesFacade(factory);\n}\n\nexport const Dates = createDates();\nexport type { DateFactoryOptions };\n","import { AutomationError } from \"@autometa/errors\";\nimport { assertKey } from \"@autometa/asserters\";\nimport { normalizeToken } from \"../shared/phrases.js\";\n\nexport type TimeDiffFn = (start: Date, end: Date) => number;\n\nconst SUPPORTED_METHODS = [\n \"minutes\",\n \"seconds\",\n \"millis\",\n \"days\",\n \"hours\",\n \"weeks\",\n] as const;\ntype MethodName = (typeof SUPPORTED_METHODS)[number];\n\nfunction toTime(date: Date): number {\n return new Date(date).getTime();\n}\n\nexport class TimeDiff {\n minutes(start: Date, end: Date): number {\n return this.millis(start, end) / 60_000;\n }\n\n seconds(start: Date, end: Date): number {\n return this.millis(start, end) / 1_000;\n }\n\n millis(start: Date, end: Date): number {\n const distance = Math.abs(toTime(end) - toTime(start));\n return Math.round(distance);\n }\n\n days(start: Date, end: Date): number {\n return this.millis(start, end) / 86_400_000;\n }\n\n hours(start: Date, end: Date): number {\n return this.millis(start, end) / 3_600_000;\n }\n\n weeks(start: Date, end: Date): number {\n return this.millis(start, end) / 604_800_000;\n }\n\n fromPhrase(phrase: unknown): TimeDiffFn {\n if (typeof phrase !== \"string\") {\n throw new AutomationError(\n `TimeDiff.fromPhrase expects a string, received '${typeof phrase}'.`\n );\n }\n\n const key = normalizeToken(phrase);\n if (!this.hasMethod(key)) {\n throw new AutomationError(\n `Unsupported diff unit '${phrase}'. Expected one of ${this.supportedMethods().join(\", \")}.`\n );\n }\n\n assertKey(this, key as MethodName, \"TimeDiff.fromPhrase\");\n const method = this[key as MethodName];\n if (typeof method !== \"function\") {\n throw new AutomationError(`Diff method '${key}' is not callable.`);\n }\n return (method as TimeDiffFn).bind(this);\n }\n\n private hasMethod(name: string): boolean {\n return SUPPORTED_METHODS.includes(name as MethodName);\n }\n\n private supportedMethods(): MethodName[] {\n return [...SUPPORTED_METHODS];\n }\n}\n","import { TimeDiff, type TimeDiffFn } from \"./time-diff.js\";\n\nexport interface TimeFactory {\n readonly diff: TimeDiff;\n}\n\nclass TimeFacade implements TimeFactory {\n readonly diff: TimeDiff;\n\n constructor(diff: TimeDiff) {\n this.diff = diff;\n }\n}\n\nexport function createTime(): TimeFactory {\n return new TimeFacade(new TimeDiff());\n}\n\nexport const Time = createTime();\nexport { TimeDiff, type TimeDiffFn };\n"]}
package/dist/index.d.ts CHANGED
@@ -1,219 +1,6 @@
1
- import { TimeUnit } from '@autometa/phrases';
2
-
3
- type TimeShortcut = "now" | "beforeYesterday" | "yesterday" | "today" | "tomorrow" | "afterTomorrow" | "midnight" | "lastWeek" | "nextWeek" | "lastFortnight" | "nextFortnight";
4
- declare class DateFactory {
5
- #private;
6
- phraseMap: Map<TimeShortcut, () => Date>;
7
- find(name: TimeShortcut): Date;
8
- fromPhraseSafe(phrase: string): Date | undefined;
9
- fromPhrase(phrase: string): Date;
10
- make(timeOffset: number, timeunit: TimeUnit): Date;
11
- }
12
-
13
- declare class IsoDateFactory {
14
- readonly dateFactory: DateFactory;
15
- constructor(dateFactory: DateFactory);
16
- phraseMap: Map<string, string>;
17
- make(daysOffset: number, timeunit: TimeUnit): string;
18
- /**
19
- * Attempts to parse a phrase into a date.
20
- * @param phrase
21
- * @returns
22
- */
23
- fromPhrase(phrase: string): string;
24
- /**
25
- * Returns the date and time of the day before yesterday
26
- */
27
- get beforeYesterday(): string | undefined;
28
- /**
29
- * Returns the date and time of yesterday
30
- */
31
- get yesterday(): string | undefined;
32
- /**
33
- * Returns the date and time of today
34
- */
35
- get today(): string | undefined;
36
- /**
37
- * Returns the date and time of tomorrow
38
- */
39
- get tomorrow(): string | undefined;
40
- /**
41
- * Returns the date and time of the day after tomorrow
42
- */
43
- get afterTomorrow(): string | undefined;
44
- /**
45
- * Returns the date and time of midnight today
46
- */
47
- get midnight(): string | undefined;
48
- /**
49
- * Returns the date and time of today 1 week ago
50
- */
51
- get lastWeek(): string | undefined;
52
- /**
53
- * Returns the date and time of today 1 week from now
54
- */
55
- get nextWeek(): string | undefined;
56
- get lastFortnight(): string | undefined;
57
- /**
58
- * Returns the date and time of today 1 fortnight from now
59
- */
60
- get nextFortnight(): string | undefined;
61
- }
62
-
63
- declare class FmtDateFactory {
64
- readonly dateFactory: DateFactory;
65
- constructor(dateFactory: DateFactory);
66
- phraseMap: Map<string, string>;
67
- make(daysOffset: number, timeunit: TimeUnit): string;
68
- /**
69
- * Attempts to parse a phrase into a date.
70
- * @param phrase
71
- * @returns
72
- */
73
- fromPhrase(phrase: string): string;
74
- /**
75
- * Returns the date and time of the day before yesterday
76
- */
77
- get beforeYesterday(): string | undefined;
78
- /**
79
- * Returns the date and time of yesterday
80
- */
81
- get yesterday(): string | undefined;
82
- /**
83
- * Returns the date and time of today
84
- */
85
- get today(): string | undefined;
86
- /**
87
- * Returns the date and time of tomorrow
88
- */
89
- get tomorrow(): string | undefined;
90
- /**
91
- * Returns the date and time of the day after tomorrow
92
- */
93
- get afterTomorrow(): string | undefined;
94
- /**
95
- * Returns the date and time of midnight today
96
- */
97
- get midnight(): string | undefined;
98
- /**
99
- * Returns the date and time of today 1 week ago
100
- */
101
- get lastWeek(): string | undefined;
102
- /**
103
- * Returns the date and time of today 1 week from now
104
- */
105
- get nextWeek(): string | undefined;
106
- /**
107
- * Returns the date and time of today 1 fortnight ago
108
- */
109
- get lastFortnight(): string | undefined;
110
- /**
111
- * Returns the date and time of today 1 fortnight from now
112
- */
113
- get nextFortnight(): string | undefined;
114
- }
115
-
116
- declare class DatesObject {
117
- #private;
118
- /**
119
- * Switches to the ISO factory, which offers an identical interface
120
- * but returns ISO strings instead of Date objects.
121
- *
122
- * Example: `2020-01-01T00:00:00.000Z`
123
- */
124
- get iso(): IsoDateFactory;
125
- /**
126
- * Switches to the formatted factory, which offers an identical interface
127
- * but returns formatted strings instead of Date objects.
128
- *
129
- * Example: `2020-01-01`
130
- */
131
- get fmt(): FmtDateFactory;
132
- /**
133
- * Returns the current date and time.
134
- */
135
- get now(): Date;
136
- /**
137
- * Returns the date and time of the day before yesterday
138
- */
139
- get beforeYesterday(): Date;
140
- /**
141
- * Returns the date and time of yesterday
142
- */
143
- get yesterday(): Date;
144
- /**
145
- * Returns the date and time of today
146
- */
147
- get today(): Date;
148
- /**
149
- * Returns the date and time of tomorrow
150
- */
151
- get tomorrow(): Date;
152
- /**
153
- * Returns the date and time of the day after tomorrow
154
- */
155
- get afterTomorrow(): Date;
156
- /**
157
- * Returns the date and time of midnight today
158
- */
159
- get midnight(): Date;
160
- /**
161
- * Returns the date and time of today 1 week ago
162
- */
163
- get lastWeek(): Date;
164
- /**
165
- * Returns the date and time of today 1 week from now
166
- */
167
- get nextWeek(): Date;
168
- /**
169
- * Returns the date and time of today 2 weeks ago
170
- */
171
- get lastFortnight(): Date;
172
- /**
173
- * Returns the date and time of today 2 weeks from now
174
- */
175
- get nextFortnight(): Date;
176
- /**
177
- * Attempts to parse a phrase into a date.
178
- * @param phrase
179
- * @returns
180
- */
181
- fromPhrase(phrase: string): Date;
182
- /**
183
- * Attempts to parse a phrase into a date.
184
- * If the phrase is invalid, it will return an invalid date instead of throwing.
185
- * @param phrase
186
- * @returns
187
- */
188
- fromPhraseSafe(phrase: string): Date | undefined;
189
- make(timeOffset: number, timeUnit: TimeUnit): Date;
190
- }
191
- /**
192
- * Date utility option to easily generate common
193
- * dates around the current date, like 'today', 'midnight',
194
- * 'tomorrow', 'nextWeek', etc.
195
- *
196
- * The Dates utility also supports certain language phrases
197
- * that might be natural in Cucumber's gherkin syntax, like
198
- * 'next week', 'last week', 'next fortnight', etc. as well
199
- * as more dynamic phrases like `1 day ago`, `2 weeks from now`,
200
- */
201
- declare const Dates: DatesObject;
202
-
203
- type TimeDiffFn = (date1: Date, date2: Date) => number;
204
- declare class TimeDiff {
205
- minutes(date1: Date, date2: Date): number;
206
- seconds(date1: Date, date2: Date): number;
207
- millis(date1: Date, date2: Date): number;
208
- days(date1: Date, date2: Date): number;
209
- hours(date1: Date, date2: Date): number;
210
- weeks(date1: Date, date2: Date): number;
211
- fromPhrase(phrase: string): TimeDiffFn;
212
- }
213
- declare class TimeObject {
214
- #private;
215
- get diff(): TimeDiff;
216
- }
217
- declare const Time: TimeObject;
218
-
219
- export { DateFactory, Dates, FmtDateFactory, IsoDateFactory, Time, TimeDiff, TimeObject };
1
+ export type { Clock } from "./dates/clock.js";
2
+ export { createDates, Dates, type DatesOptions, type DatesObject, } from "./dates/object.js";
3
+ export { DateFactory, type DateFactoryOptions, } from "./dates/date-factory.js";
4
+ export { IsoDateFactory, type IsoDateFactoryOptions, } from "./dates/iso-date-factory.js";
5
+ export { FormattedDateFactory, type FormattedDateFactoryOptions, } from "./dates/formatted-date-factory.js";
6
+ export { Time, createTime, TimeDiff, type TimeDiffFn, } from "./time/time.js";