@f-o-t/datetime 0.1.0 → 0.1.4
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.
- package/dist/core/datetime.d.ts +341 -0
- package/dist/core/datetime.d.ts.map +1 -0
- package/{src/core/factory.ts → dist/core/factory.d.ts} +2 -4
- package/dist/core/factory.d.ts.map +1 -0
- package/dist/errors.d.ts +43 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index-77f5wgyc.js +41 -0
- package/dist/index-77f5wgyc.js.map +10 -0
- package/dist/index-9jdtsp4s.js +55 -0
- package/dist/index-9jdtsp4s.js.map +10 -0
- package/dist/index-a78jd9k6.js +64 -0
- package/dist/index-a78jd9k6.js.map +10 -0
- package/dist/index-rtm7bpky.js +86 -0
- package/dist/index-rtm7bpky.js.map +10 -0
- package/dist/index-v3cytzbp.js +105 -0
- package/dist/index-v3cytzbp.js.map +11 -0
- package/{src/index.ts → dist/index.d.ts} +2 -15
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +390 -0
- package/dist/index.js.map +13 -0
- package/dist/plugins/business-days/index.d.ts +45 -0
- package/dist/plugins/business-days/index.d.ts.map +1 -0
- package/dist/plugins/business-days/index.js +10 -0
- package/dist/plugins/business-days/index.js.map +9 -0
- package/dist/plugins/format/index.d.ts +54 -0
- package/dist/plugins/format/index.d.ts.map +1 -0
- package/dist/plugins/format/index.js +10 -0
- package/dist/plugins/format/index.js.map +9 -0
- package/dist/plugins/format/tokens.d.ts +20 -0
- package/dist/plugins/format/tokens.d.ts.map +1 -0
- package/{src/plugins/index.ts → dist/plugins/index.d.ts} +1 -2
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/plugin-base.d.ts +49 -0
- package/dist/plugins/plugin-base.d.ts.map +1 -0
- package/dist/plugins/relative-time/index.d.ts +61 -0
- package/dist/plugins/relative-time/index.d.ts.map +1 -0
- package/dist/plugins/relative-time/index.js +10 -0
- package/dist/plugins/relative-time/index.js.map +9 -0
- package/dist/plugins/timezone/index.d.ts +59 -0
- package/dist/plugins/timezone/index.d.ts.map +1 -0
- package/dist/plugins/timezone/index.js +10 -0
- package/dist/plugins/timezone/index.js.map +9 -0
- package/dist/schemas.d.ts +66 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/types.d.ts +96 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +50 -45
- package/CHANGELOG.md +0 -13
- package/biome.json +0 -39
- package/bunup.config.ts +0 -14
- package/examples/plugins-demo.ts +0 -85
- package/fot.config.ts +0 -5
- package/src/core/datetime.test.ts +0 -1498
- package/src/core/datetime.ts +0 -694
- package/src/core/factory.test.ts +0 -167
- package/src/errors.ts +0 -82
- package/src/plugins/business-days/business-days.test.ts +0 -225
- package/src/plugins/business-days/index.ts +0 -126
- package/src/plugins/format/format.test.ts +0 -173
- package/src/plugins/format/index.ts +0 -78
- package/src/plugins/format/tokens.ts +0 -153
- package/src/plugins/plugin-base.test.ts +0 -211
- package/src/plugins/plugin-base.ts +0 -104
- package/src/plugins/relative-time/index.ts +0 -169
- package/src/plugins/relative-time/relative-time.test.ts +0 -164
- package/src/plugins/timezone/index.ts +0 -152
- package/src/plugins/timezone/timezone.test.ts +0 -135
- package/src/schemas.test.ts +0 -283
- package/src/schemas.ts +0 -104
- package/src/types.ts +0 -122
- package/tsconfig.json +0 -29
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/errors.ts", "../src/schemas.ts", "../src/core/datetime.ts", "../src/core/factory.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Base error class for all DateTime-related errors\n */\nexport class DateTimeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"DateTimeError\";\n // Maintains proper stack trace for where our error was thrown (only available on V8)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n}\n\n/**\n * Error thrown when an invalid date is provided\n */\nexport class InvalidDateError extends DateTimeError {\n constructor(\n message = \"Invalid date\",\n public readonly input?: unknown,\n ) {\n super(message);\n this.name = \"InvalidDateError\";\n }\n}\n\n/**\n * Error thrown when a date string doesn't match the expected format\n */\nexport class InvalidFormatError extends DateTimeError {\n constructor(\n message: string,\n public readonly input?: string,\n public readonly expectedFormat?: string,\n ) {\n super(message);\n this.name = \"InvalidFormatError\";\n }\n}\n\n/**\n * Error thrown when an invalid timezone is specified\n */\nexport class InvalidTimezoneError extends DateTimeError {\n constructor(\n message: string,\n public readonly timezone?: string,\n ) {\n super(message);\n this.name = \"InvalidTimezoneError\";\n }\n}\n\n/**\n * Error thrown when a plugin operation fails\n */\nexport class PluginError extends DateTimeError {\n constructor(\n message: string,\n public readonly pluginName?: string,\n ) {\n super(message);\n this.name = \"PluginError\";\n }\n}\n\n/**\n * Error thrown when attempting to use functionality that requires a plugin that isn't installed\n */\nexport class MissingPluginError extends PluginError {\n constructor(\n public readonly requiredPlugin: string,\n message?: string,\n ) {\n super(\n message || `Missing required plugin: ${requiredPlugin}`,\n requiredPlugin,\n );\n this.name = \"MissingPluginError\";\n }\n}\n",
|
|
6
|
+
"import { z } from \"zod\";\nimport type { DateTime } from \"./types\";\n\n/**\n * Schema for time units\n */\nexport const TimeUnitSchema = z.enum([\n \"millisecond\",\n \"second\",\n \"minute\",\n \"hour\",\n \"day\",\n \"week\",\n \"month\",\n \"year\",\n]);\n\n/**\n * Schema for DateTime input types\n * Accepts Date, string, number, or DateTime instance\n */\nexport const DateInputSchema = z.union([\n z.date(),\n z.string(),\n z.number(),\n z.custom<DateTime>(\n (val) =>\n val !== null &&\n typeof val === \"object\" &&\n \"toDate\" in val &&\n typeof val.toDate === \"function\",\n {\n message: \"Expected DateTime instance\",\n },\n ),\n]);\n\n/**\n * Schema for DateTime configuration\n */\nexport const DateTimeConfigSchema = z.object({\n timezone: z.string().optional(),\n locale: z.string().optional(),\n utc: z.boolean().optional(),\n strict: z.boolean().optional(),\n});\n\n/**\n * Schema for format options\n */\nexport const FormatOptionsSchema = z.object({\n locale: z.string().optional(),\n timezone: z.string().optional(),\n});\n\n/**\n * Schema for parse options\n */\nexport const ParseOptionsSchema = z.object({\n strict: z.boolean().optional(),\n format: z.string().optional(),\n timezone: z.string().optional(),\n});\n\n/**\n * Schema for ISO 8601 date strings (full datetime with timezone)\n * Matches: YYYY-MM-DDTHH:mm:ss.sssZ or YYYY-MM-DDTHH:mm:ss.sss±HH:mm\n */\nexport const ISODateSchema = z\n .string()\n .regex(\n /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,3})?(Z|[+-]\\d{2}:\\d{2})$/,\n {\n message:\n \"Invalid ISO 8601 datetime format. Expected: YYYY-MM-DDTHH:mm:ss.sssZ\",\n },\n );\n\n/**\n * Schema for ISO 8601 date-only strings\n * Matches: YYYY-MM-DD\n */\nexport const ISODateOnlySchema = z.string().regex(/^\\d{4}-\\d{2}-\\d{2}$/, {\n message: \"Invalid ISO 8601 date format. Expected: YYYY-MM-DD\",\n});\n\n/**\n * Schema for ISO 8601 time-only strings\n * Matches: HH:mm:ss or HH:mm:ss.sss\n */\nexport const ISOTimeOnlySchema = z\n .string()\n .regex(/^\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,3})?$/, {\n message:\n \"Invalid ISO 8601 time format. Expected: HH:mm:ss or HH:mm:ss.sss\",\n });\n\n/**\n * Schema for plugin definition\n */\nexport const DateTimePluginSchema = z.object({\n name: z.string().min(1, \"Plugin name cannot be empty\"),\n install: z.function(),\n});\n",
|
|
7
|
+
"import { InvalidDateError, PluginError } from \"../errors\";\nimport { DateInputSchema } from \"../schemas\";\nimport type { DateInput, DateTimePlugin, TimeUnit } from \"../types\";\n\n/**\n * Core DateTime class that wraps the native JavaScript Date object\n * Provides immutable operations and extensibility through plugins\n */\nexport class DateTime {\n /**\n * Internal date storage\n * @private\n */\n private readonly _date: Date;\n\n /**\n * Static registry of installed plugins\n * @private\n */\n private static readonly plugins: Map<string, DateTimePlugin> = new Map();\n\n /**\n * Creates a new DateTime instance\n * @param input - Date input (Date, ISO string, timestamp, DateTime, or undefined for current time)\n * @throws {InvalidDateError} When input fails Zod validation\n */\n constructor(input?: DateInput) {\n // If no input provided, use current time\n if (input === undefined) {\n this._date = new Date();\n return;\n }\n\n // Special handling for NaN - allow it but create invalid date\n if (typeof input === \"number\" && Number.isNaN(input)) {\n this._date = new Date(NaN);\n return;\n }\n\n // Special handling for Invalid Date objects - allow them through\n if (input instanceof Date && Number.isNaN(input.getTime())) {\n this._date = new Date(input.getTime());\n return;\n }\n\n // Validate input with Zod schema\n const validation = DateInputSchema.safeParse(input);\n if (!validation.success) {\n throw new InvalidDateError(\n `Invalid date input: ${validation.error.message}`,\n input,\n );\n }\n\n // Convert input to Date\n if (input instanceof Date) {\n // Clone the date to ensure immutability\n this._date = new Date(input.getTime());\n } else if (typeof input === \"string\") {\n // Parse ISO string or other date string\n // This may result in an Invalid Date, which is allowed\n this._date = new Date(input);\n } else if (typeof input === \"number\") {\n // Use timestamp\n this._date = new Date(input);\n } else if (this.isDateTimeInstance(input)) {\n // Clone from another DateTime instance\n this._date = new Date(input.valueOf());\n } else {\n // Should never reach here due to Zod validation, but TypeScript needs it\n throw new InvalidDateError(\"Unsupported date input type\", input);\n }\n }\n\n /**\n * Type guard to check if value is a DateTime instance\n * @private\n */\n private isDateTimeInstance(val: unknown): val is DateTime {\n return (\n val !== null &&\n typeof val === \"object\" &&\n \"toDate\" in val &&\n typeof val.toDate === \"function\"\n );\n }\n\n /**\n * Checks if the date is valid\n * @returns true if the date is valid, false otherwise\n */\n public isValid(): boolean {\n return !Number.isNaN(this._date.getTime());\n }\n\n /**\n * Returns the native JavaScript Date object (cloned for immutability)\n * @returns A clone of the internal Date object\n */\n public toDate(): Date {\n return new Date(this._date.getTime());\n }\n\n /**\n * Returns ISO 8601 string representation\n * @returns ISO 8601 formatted string\n */\n public toISO(): string {\n return this._date.toISOString();\n }\n\n /**\n * Returns the Unix timestamp in milliseconds\n * @returns Unix timestamp\n */\n public valueOf(): number {\n return this._date.getTime();\n }\n\n // ============================================\n // Arithmetic Methods\n // ============================================\n\n /**\n * Adds milliseconds to the date\n * @param amount - Number of milliseconds to add (can be negative)\n * @returns New DateTime instance with added milliseconds\n */\n public addMilliseconds(amount: number): DateTime {\n return new DateTime(this.valueOf() + amount);\n }\n\n /**\n * Adds seconds to the date\n * @param amount - Number of seconds to add (can be negative)\n * @returns New DateTime instance with added seconds\n */\n public addSeconds(amount: number): DateTime {\n return this.addMilliseconds(amount * 1000);\n }\n\n /**\n * Adds minutes to the date\n * @param amount - Number of minutes to add (can be negative)\n * @returns New DateTime instance with added minutes\n */\n public addMinutes(amount: number): DateTime {\n return this.addMilliseconds(amount * 60 * 1000);\n }\n\n /**\n * Adds hours to the date\n * @param amount - Number of hours to add (can be negative)\n * @returns New DateTime instance with added hours\n */\n public addHours(amount: number): DateTime {\n return this.addMilliseconds(amount * 60 * 60 * 1000);\n }\n\n /**\n * Adds days to the date\n * @param amount - Number of days to add (can be negative)\n * @returns New DateTime instance with added days\n */\n public addDays(amount: number): DateTime {\n const newDate = this.toDate();\n newDate.setDate(newDate.getDate() + amount);\n return new DateTime(newDate);\n }\n\n /**\n * Adds weeks to the date\n * @param amount - Number of weeks to add (can be negative)\n * @returns New DateTime instance with added weeks\n */\n public addWeeks(amount: number): DateTime {\n return this.addDays(amount * 7);\n }\n\n /**\n * Adds months to the date\n * @param amount - Number of months to add (can be negative)\n * @returns New DateTime instance with added months\n */\n public addMonths(amount: number): DateTime {\n const newDate = this.toDate();\n newDate.setMonth(newDate.getMonth() + amount);\n return new DateTime(newDate);\n }\n\n /**\n * Adds years to the date\n * @param amount - Number of years to add (can be negative)\n * @returns New DateTime instance with added years\n */\n public addYears(amount: number): DateTime {\n const newDate = this.toDate();\n newDate.setFullYear(newDate.getFullYear() + amount);\n return new DateTime(newDate);\n }\n\n /**\n * Subtracts milliseconds from the date\n * @param amount - Number of milliseconds to subtract (can be negative)\n * @returns New DateTime instance with subtracted milliseconds\n */\n public subtractMilliseconds(amount: number): DateTime {\n return this.addMilliseconds(-amount);\n }\n\n /**\n * Subtracts seconds from the date\n * @param amount - Number of seconds to subtract (can be negative)\n * @returns New DateTime instance with subtracted seconds\n */\n public subtractSeconds(amount: number): DateTime {\n return this.addSeconds(-amount);\n }\n\n /**\n * Subtracts minutes from the date\n * @param amount - Number of minutes to subtract (can be negative)\n * @returns New DateTime instance with subtracted minutes\n */\n public subtractMinutes(amount: number): DateTime {\n return this.addMinutes(-amount);\n }\n\n /**\n * Subtracts hours from the date\n * @param amount - Number of hours to subtract (can be negative)\n * @returns New DateTime instance with subtracted hours\n */\n public subtractHours(amount: number): DateTime {\n return this.addHours(-amount);\n }\n\n /**\n * Subtracts days from the date\n * @param amount - Number of days to subtract (can be negative)\n * @returns New DateTime instance with subtracted days\n */\n public subtractDays(amount: number): DateTime {\n return this.addDays(-amount);\n }\n\n /**\n * Subtracts weeks from the date\n * @param amount - Number of weeks to subtract (can be negative)\n * @returns New DateTime instance with subtracted weeks\n */\n public subtractWeeks(amount: number): DateTime {\n return this.addWeeks(-amount);\n }\n\n /**\n * Subtracts months from the date\n * @param amount - Number of months to subtract (can be negative)\n * @returns New DateTime instance with subtracted months\n */\n public subtractMonths(amount: number): DateTime {\n return this.addMonths(-amount);\n }\n\n /**\n * Subtracts years from the date\n * @param amount - Number of years to subtract (can be negative)\n * @returns New DateTime instance with subtracted years\n */\n public subtractYears(amount: number): DateTime {\n return this.addYears(-amount);\n }\n\n // ============================================\n // Comparison Methods\n // ============================================\n\n /**\n * Checks if this date is before another date\n * @param other - DateTime instance to compare against\n * @returns true if this date is before the other date, false otherwise\n */\n public isBefore(other: DateTime): boolean {\n return this.valueOf() < other.valueOf();\n }\n\n /**\n * Checks if this date is after another date\n * @param other - DateTime instance to compare against\n * @returns true if this date is after the other date, false otherwise\n */\n public isAfter(other: DateTime): boolean {\n return this.valueOf() > other.valueOf();\n }\n\n /**\n * Checks if this date is the same as another date\n * @param other - DateTime instance to compare against\n * @returns true if this date is the same as the other date, false otherwise\n */\n public isSame(other: DateTime): boolean {\n return this.valueOf() === other.valueOf();\n }\n\n /**\n * Checks if this date is the same as or before another date\n * @param other - DateTime instance to compare against\n * @returns true if this date is the same as or before the other date, false otherwise\n */\n public isSameOrBefore(other: DateTime): boolean {\n return this.valueOf() <= other.valueOf();\n }\n\n /**\n * Checks if this date is the same as or after another date\n * @param other - DateTime instance to compare against\n * @returns true if this date is the same as or after the other date, false otherwise\n */\n public isSameOrAfter(other: DateTime): boolean {\n return this.valueOf() >= other.valueOf();\n }\n\n /**\n * Checks if this date is between two dates\n * @param start - Start date of the range\n * @param end - End date of the range\n * @param inclusive - Whether to include the start and end dates in the comparison (default: false)\n * @returns true if this date is between start and end, false otherwise\n */\n public isBetween(\n start: DateTime,\n end: DateTime,\n inclusive = false,\n ): boolean {\n const thisTime = this.valueOf();\n const startTime = start.valueOf();\n const endTime = end.valueOf();\n\n if (inclusive) {\n return thisTime >= startTime && thisTime <= endTime;\n }\n return thisTime > startTime && thisTime < endTime;\n }\n\n // ============================================\n // Getter Methods\n // ============================================\n\n /**\n * Gets the UTC year\n * @returns The year (e.g., 2024)\n */\n public year(): number {\n return this._date.getUTCFullYear();\n }\n\n /**\n * Gets the UTC month (0-indexed)\n * @returns The month (0-11, where 0=January)\n */\n public month(): number {\n return this._date.getUTCMonth();\n }\n\n /**\n * Gets the UTC day of the month\n * @returns The day of month (1-31)\n */\n public date(): number {\n return this._date.getUTCDate();\n }\n\n /**\n * Gets the UTC day of the week (0-indexed)\n * @returns The day of week (0-6, where 0=Sunday)\n */\n public day(): number {\n return this._date.getUTCDay();\n }\n\n /**\n * Gets the UTC hour\n * @returns The hour (0-23)\n */\n public hour(): number {\n return this._date.getUTCHours();\n }\n\n /**\n * Gets the UTC minute\n * @returns The minute (0-59)\n */\n public minute(): number {\n return this._date.getUTCMinutes();\n }\n\n /**\n * Gets the UTC second\n * @returns The second (0-59)\n */\n public second(): number {\n return this._date.getUTCSeconds();\n }\n\n /**\n * Gets the UTC millisecond\n * @returns The millisecond (0-999)\n */\n public millisecond(): number {\n return this._date.getUTCMilliseconds();\n }\n\n // ============================================\n // Setter Methods\n // ============================================\n\n /**\n * Sets the UTC year\n * @param year - The year to set\n * @returns New DateTime instance with updated year\n */\n public setYear(year: number): DateTime {\n const newDate = this.toDate();\n newDate.setUTCFullYear(year);\n return new DateTime(newDate);\n }\n\n /**\n * Sets the UTC month (0-indexed)\n * @param month - The month to set (0-11, where 0=January)\n * @returns New DateTime instance with updated month\n */\n public setMonth(month: number): DateTime {\n const newDate = this.toDate();\n newDate.setUTCMonth(month);\n return new DateTime(newDate);\n }\n\n /**\n * Sets the UTC day of the month\n * @param date - The day to set (1-31)\n * @returns New DateTime instance with updated date\n */\n public setDate(date: number): DateTime {\n const newDate = this.toDate();\n newDate.setUTCDate(date);\n return new DateTime(newDate);\n }\n\n /**\n * Sets the UTC hour\n * @param hour - The hour to set (0-23)\n * @returns New DateTime instance with updated hour\n */\n public setHour(hour: number): DateTime {\n const newDate = this.toDate();\n newDate.setUTCHours(hour);\n return new DateTime(newDate);\n }\n\n /**\n * Sets the UTC minute\n * @param minute - The minute to set (0-59)\n * @returns New DateTime instance with updated minute\n */\n public setMinute(minute: number): DateTime {\n const newDate = this.toDate();\n newDate.setUTCMinutes(minute);\n return new DateTime(newDate);\n }\n\n /**\n * Sets the UTC second\n * @param second - The second to set (0-59)\n * @returns New DateTime instance with updated second\n */\n public setSecond(second: number): DateTime {\n const newDate = this.toDate();\n newDate.setUTCSeconds(second);\n return new DateTime(newDate);\n }\n\n /**\n * Sets the UTC millisecond\n * @param millisecond - The millisecond to set (0-999)\n * @returns New DateTime instance with updated millisecond\n */\n public setMillisecond(millisecond: number): DateTime {\n const newDate = this.toDate();\n newDate.setUTCMilliseconds(millisecond);\n return new DateTime(newDate);\n }\n\n // ============================================\n // Start/End Methods\n // ============================================\n\n /**\n * Returns a new DateTime at the start of the day (00:00:00.000)\n * @returns New DateTime instance at start of day\n */\n public startOfDay(): DateTime {\n const newDate = this.toDate();\n newDate.setUTCHours(0, 0, 0, 0);\n return new DateTime(newDate);\n }\n\n /**\n * Returns a new DateTime at the end of the day (23:59:59.999)\n * @returns New DateTime instance at end of day\n */\n public endOfDay(): DateTime {\n const newDate = this.toDate();\n newDate.setUTCHours(23, 59, 59, 999);\n return new DateTime(newDate);\n }\n\n /**\n * Returns a new DateTime at the start of the hour (XX:00:00.000)\n * @returns New DateTime instance at start of hour\n */\n public startOfHour(): DateTime {\n const newDate = this.toDate();\n newDate.setUTCMinutes(0, 0, 0);\n return new DateTime(newDate);\n }\n\n /**\n * Returns a new DateTime at the end of the hour (XX:59:59.999)\n * @returns New DateTime instance at end of hour\n */\n public endOfHour(): DateTime {\n const newDate = this.toDate();\n newDate.setUTCMinutes(59, 59, 999);\n return new DateTime(newDate);\n }\n\n /**\n * Returns a new DateTime at the start of the week (Sunday 00:00:00.000)\n * @returns New DateTime instance at start of week\n */\n public startOfWeek(): DateTime {\n const newDate = this.toDate();\n const day = newDate.getUTCDay();\n newDate.setUTCDate(newDate.getUTCDate() - day);\n newDate.setUTCHours(0, 0, 0, 0);\n return new DateTime(newDate);\n }\n\n /**\n * Returns a new DateTime at the end of the week (Saturday 23:59:59.999)\n * @returns New DateTime instance at end of week\n */\n public endOfWeek(): DateTime {\n const newDate = this.toDate();\n const day = newDate.getUTCDay();\n newDate.setUTCDate(newDate.getUTCDate() + (6 - day));\n newDate.setUTCHours(23, 59, 59, 999);\n return new DateTime(newDate);\n }\n\n /**\n * Returns a new DateTime at the start of the month (day 1, 00:00:00.000)\n * @returns New DateTime instance at start of month\n */\n public startOfMonth(): DateTime {\n const newDate = this.toDate();\n newDate.setUTCDate(1);\n newDate.setUTCHours(0, 0, 0, 0);\n return new DateTime(newDate);\n }\n\n /**\n * Returns a new DateTime at the end of the month (last day, 23:59:59.999)\n * @returns New DateTime instance at end of month\n */\n public endOfMonth(): DateTime {\n const newDate = this.toDate();\n // Set to next month, day 0 (last day of current month)\n newDate.setUTCMonth(newDate.getUTCMonth() + 1, 0);\n newDate.setUTCHours(23, 59, 59, 999);\n return new DateTime(newDate);\n }\n\n /**\n * Returns a new DateTime at the start of the year (Jan 1, 00:00:00.000)\n * @returns New DateTime instance at start of year\n */\n public startOfYear(): DateTime {\n const newDate = this.toDate();\n newDate.setUTCMonth(0, 1);\n newDate.setUTCHours(0, 0, 0, 0);\n return new DateTime(newDate);\n }\n\n /**\n * Returns a new DateTime at the end of the year (Dec 31, 23:59:59.999)\n * @returns New DateTime instance at end of year\n */\n public endOfYear(): DateTime {\n const newDate = this.toDate();\n newDate.setUTCMonth(11, 31);\n newDate.setUTCHours(23, 59, 59, 999);\n return new DateTime(newDate);\n }\n\n // ============================================\n // Difference Method\n // ============================================\n\n /**\n * Calculates the difference between this date and another date\n * @param other - DateTime instance to compare against\n * @param unit - Unit of measurement (default: 'millisecond')\n * @returns The difference (can be negative)\n */\n public diff(other: DateTime, unit: TimeUnit = \"millisecond\"): number {\n const diff = this.valueOf() - other.valueOf();\n\n switch (unit) {\n case \"millisecond\":\n return diff;\n case \"second\":\n return diff / 1000;\n case \"minute\":\n return diff / (1000 * 60);\n case \"hour\":\n return diff / (1000 * 60 * 60);\n case \"day\":\n return diff / (1000 * 60 * 60 * 24);\n case \"week\":\n return diff / (1000 * 60 * 60 * 24 * 7);\n case \"month\": {\n // For months, we calculate based on the actual month difference\n const thisDate = this.toDate();\n const otherDate = other.toDate();\n const yearDiff =\n thisDate.getUTCFullYear() - otherDate.getUTCFullYear();\n const monthDiff = thisDate.getUTCMonth() - otherDate.getUTCMonth();\n return yearDiff * 12 + monthDiff;\n }\n case \"year\": {\n // For years, we calculate based on milliseconds\n // Average year length accounting for leap years\n return diff / (1000 * 60 * 60 * 24 * 365.25);\n }\n default:\n return diff;\n }\n }\n\n /**\n * Registers a plugin to extend DateTime functionality\n * @param plugin - The plugin to register\n * @param options - Optional plugin configuration\n * @throws {PluginError} When plugin with same name already exists\n */\n public static extend(\n plugin: DateTimePlugin,\n options?: Record<string, unknown>,\n ): void {\n // Check if plugin already registered\n if (DateTime.plugins.has(plugin.name)) {\n throw new PluginError(\n `Plugin ${plugin.name} is already registered`,\n plugin.name,\n );\n }\n\n // Register plugin\n DateTime.plugins.set(plugin.name, plugin);\n\n // Call plugin install function\n plugin.install(DateTime as any, options);\n }\n\n /**\n * Checks if a plugin is registered\n * @param name - Plugin name\n * @returns true if plugin is registered, false otherwise\n */\n public static hasPlugin(name: string): boolean {\n return DateTime.plugins.has(name);\n }\n\n /**\n * Gets a registered plugin\n * @param name - Plugin name\n * @returns The plugin if found, undefined otherwise\n */\n public static getPlugin(name: string): DateTimePlugin | undefined {\n return DateTime.plugins.get(name);\n }\n}\n",
|
|
8
|
+
"import type { DateInput } from \"../types.ts\";\nimport { DateTime } from \"./datetime.ts\";\n\n/**\n * Factory function to create a DateTime instance\n * Provides a convenient alternative to using the constructor\n *\n * @param input - Date input (Date, ISO string, timestamp, DateTime, or undefined for current time)\n * @returns A new DateTime instance\n * @throws {InvalidDateError} When input fails validation\n *\n * @example\n * ```ts\n * // Create with current time\n * const now = datetime();\n *\n * // Create from Date object\n * const dt1 = datetime(new Date());\n *\n * // Create from ISO string\n * const dt2 = datetime(\"2024-01-15T10:30:00Z\");\n *\n * // Create from timestamp\n * const dt3 = datetime(1705315800000);\n *\n * // Create from another DateTime\n * const dt4 = datetime(dt1);\n * ```\n */\nexport function datetime(input?: DateInput): DateTime {\n return new DateTime(input);\n}\n"
|
|
9
|
+
],
|
|
10
|
+
"mappings": ";;;;;;;;;;;;AAGO,MAAM,sBAAsB,MAAM;AAAA,EACtC,WAAW,CAAC,SAAiB;AAAA,IAC1B,MAAM,OAAO;AAAA,IACb,KAAK,OAAO;AAAA,IAEZ,IAAI,MAAM,mBAAmB;AAAA,MAC1B,MAAM,kBAAkB,MAAM,KAAK,WAAW;AAAA,IACjD;AAAA;AAEN;AAAA;AAKO,MAAM,yBAAyB,cAAc;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,MAAuB;AAAA,IAC5C,OAAO,SAAS,QAAQ,IAAI,IAAI;AAAA;AAAA,SAQrB,SAAS,CAAC,MAA0C;AAAA,IAC/D,OAAO,SAAS,QAAQ,IAAI,IAAI;AAAA;AAEtC;;ACxpBO,SAAS,QAAQ,CAAC,OAA6B;AAAA,EACnD,OAAO,IAAI,SAAS,KAAK;AAAA;",
|
|
11
|
+
"debugId": "D8EEE46614FED6E064756E2164756E21",
|
|
12
|
+
"names": []
|
|
13
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extended DateTime interface with business days methods
|
|
3
|
+
*/
|
|
4
|
+
declare module "../../core/datetime" {
|
|
5
|
+
interface DateTime {
|
|
6
|
+
/**
|
|
7
|
+
* Checks if this date is a weekday (Monday-Friday)
|
|
8
|
+
* @returns true if weekday, false otherwise
|
|
9
|
+
*/
|
|
10
|
+
isWeekday(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Checks if this date is a weekend (Saturday-Sunday)
|
|
13
|
+
* @returns true if weekend, false otherwise
|
|
14
|
+
*/
|
|
15
|
+
isWeekend(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Adds business days to this date
|
|
18
|
+
* Skips weekends (Saturday and Sunday)
|
|
19
|
+
* @param n - Number of business days to add
|
|
20
|
+
* @returns New DateTime instance with business days added
|
|
21
|
+
*/
|
|
22
|
+
addBusinessDays(n: number): DateTime;
|
|
23
|
+
/**
|
|
24
|
+
* Subtracts business days from this date
|
|
25
|
+
* Skips weekends (Saturday and Sunday)
|
|
26
|
+
* @param n - Number of business days to subtract
|
|
27
|
+
* @returns New DateTime instance with business days subtracted
|
|
28
|
+
*/
|
|
29
|
+
subtractBusinessDays(n: number): DateTime;
|
|
30
|
+
/**
|
|
31
|
+
* Calculates the number of business days between this date and another
|
|
32
|
+
* Excludes weekends from the calculation
|
|
33
|
+
* @param other - DateTime instance to compare against
|
|
34
|
+
* @returns Number of business days (positive if other is after, negative if before)
|
|
35
|
+
*/
|
|
36
|
+
diffBusinessDays(other: DateTime): number;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Business Days plugin for DateTime
|
|
41
|
+
* Adds methods for working with business days (weekdays only)
|
|
42
|
+
* Week is defined as Monday-Friday (weekdays), Saturday-Sunday (weekend)
|
|
43
|
+
*/
|
|
44
|
+
export declare const businessDaysPlugin: import("../..").DateTimePlugin;
|
|
45
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/business-days/index.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,OAAO,QAAQ,qBAAqB,CAAC;IAClC,UAAU,QAAQ;QACf;;;WAGG;QACH,SAAS,IAAI,OAAO,CAAC;QAErB;;;WAGG;QACH,SAAS,IAAI,OAAO,CAAC;QAErB;;;;;WAKG;QACH,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;QAErC;;;;;WAKG;QACH,oBAAoB,CAAC,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;QAE1C;;;;;WAKG;QACH,gBAAgB,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAAC;KAC5C;CACH;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,gCAgE9B,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extended DateTime interface with format method
|
|
3
|
+
*/
|
|
4
|
+
declare module "../../core/datetime" {
|
|
5
|
+
interface DateTime {
|
|
6
|
+
/**
|
|
7
|
+
* Formats the date using a format string
|
|
8
|
+
* @param formatStr - Format string with tokens (default: ISO format)
|
|
9
|
+
* @returns Formatted date string
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* dt.format("YYYY-MM-DD") // "2024-01-15"
|
|
14
|
+
* dt.format("MM/DD/YYYY") // "01/15/2024"
|
|
15
|
+
* dt.format("MMMM D, YYYY") // "January 15, 2024"
|
|
16
|
+
* dt.format("h:mm A") // "2:30 PM"
|
|
17
|
+
* dt.format("[Year:] YYYY") // "Year: 2024"
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Available tokens:
|
|
21
|
+
* - YYYY: 4-digit year
|
|
22
|
+
* - YY: 2-digit year
|
|
23
|
+
* - MMMM: Full month name
|
|
24
|
+
* - MMM: Abbreviated month name
|
|
25
|
+
* - MM: 2-digit month
|
|
26
|
+
* - M: Month number
|
|
27
|
+
* - DD: 2-digit day of month
|
|
28
|
+
* - D: Day of month
|
|
29
|
+
* - dddd: Full day name
|
|
30
|
+
* - ddd: Abbreviated day name
|
|
31
|
+
* - dd: Min day name
|
|
32
|
+
* - d: Day of week (0-6)
|
|
33
|
+
* - HH: 2-digit hour (24-hour)
|
|
34
|
+
* - H: Hour (24-hour)
|
|
35
|
+
* - hh: 2-digit hour (12-hour)
|
|
36
|
+
* - h: Hour (12-hour)
|
|
37
|
+
* - mm: 2-digit minute
|
|
38
|
+
* - m: Minute
|
|
39
|
+
* - ss: 2-digit second
|
|
40
|
+
* - s: Second
|
|
41
|
+
* - SSS: Millisecond
|
|
42
|
+
* - A: AM/PM (uppercase)
|
|
43
|
+
* - a: am/pm (lowercase)
|
|
44
|
+
* - [text]: Escaped text (literal)
|
|
45
|
+
*/
|
|
46
|
+
format(formatStr?: string): string;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Format plugin for DateTime
|
|
51
|
+
* Adds format() method for custom date formatting
|
|
52
|
+
*/
|
|
53
|
+
export declare const formatPlugin: import("../..").DateTimePlugin;
|
|
54
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/format/index.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,OAAO,QAAQ,qBAAqB,CAAC;IAClC,UAAU,QAAQ;QACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAuCG;QACH,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KACrC;CACH;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,gCAcxB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DateTime } from "../../core/datetime";
|
|
2
|
+
/**
|
|
3
|
+
* Format token definitions
|
|
4
|
+
* Maps token strings to functions that extract the value from a DateTime instance
|
|
5
|
+
*/
|
|
6
|
+
export declare const FORMAT_TOKENS: Record<string, (dt: DateTime) => string>;
|
|
7
|
+
/**
|
|
8
|
+
* Regular expression to match format tokens
|
|
9
|
+
* Matches escaped text first, then longest tokens to avoid partial matches
|
|
10
|
+
* Order is critical: longer tokens must come before shorter ones
|
|
11
|
+
*/
|
|
12
|
+
export declare const TOKEN_REGEX: RegExp;
|
|
13
|
+
/**
|
|
14
|
+
* Parses a format string and replaces tokens with actual values
|
|
15
|
+
* @param dt - DateTime instance
|
|
16
|
+
* @param formatStr - Format string with tokens
|
|
17
|
+
* @returns Formatted date string
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseFormat(dt: DateTime, formatStr: string): string;
|
|
20
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/plugins/format/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAoEpD;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,MAAM,CAqDlE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAC+D,CAAC;AAExF;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAWnE"}
|
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module plugins
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
9
|
export { businessDaysPlugin } from "./business-days/index.ts";
|
|
11
10
|
export { formatPlugin } from "./format/index.ts";
|
|
12
11
|
export { createPlugin, isPlugin, isValidPluginName } from "./plugin-base.ts";
|
|
13
12
|
export { relativeTimePlugin } from "./relative-time/index.ts";
|
|
14
|
-
// Core plugins
|
|
15
13
|
export { timezonePlugin } from "./timezone/index.ts";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { DateTimeClass, DateTimePlugin } from "../types.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to create a DateTime plugin
|
|
4
|
+
*
|
|
5
|
+
* @param name - Unique plugin name
|
|
6
|
+
* @param install - Installation function that extends the DateTime class
|
|
7
|
+
* @returns A DateTimePlugin object
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const myPlugin = createPlugin("myPlugin", (DateTimeClass, options) => {
|
|
12
|
+
* // Extend DateTime prototype
|
|
13
|
+
* DateTimeClass.prototype.myMethod = function() {
|
|
14
|
+
* return this.valueOf();
|
|
15
|
+
* };
|
|
16
|
+
*
|
|
17
|
+
* // Add static methods
|
|
18
|
+
* DateTimeClass.myStaticMethod = function() {
|
|
19
|
+
* return new DateTimeClass();
|
|
20
|
+
* };
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Register the plugin
|
|
24
|
+
* DateTime.extend(myPlugin);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function createPlugin(name: string, install: (DateTimeClass: DateTimeClass, options?: Record<string, unknown>) => void): DateTimePlugin;
|
|
28
|
+
/**
|
|
29
|
+
* Type guard to check if an object is a valid DateTimePlugin
|
|
30
|
+
*
|
|
31
|
+
* @param obj - Object to check
|
|
32
|
+
* @returns true if object is a valid DateTimePlugin
|
|
33
|
+
*/
|
|
34
|
+
export declare function isPlugin(obj: unknown): obj is DateTimePlugin;
|
|
35
|
+
/**
|
|
36
|
+
* Validates that a plugin name follows naming conventions
|
|
37
|
+
*
|
|
38
|
+
* @param name - Plugin name to validate
|
|
39
|
+
* @returns true if name is valid, false otherwise
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* Valid plugin names:
|
|
43
|
+
* - Must be a non-empty string
|
|
44
|
+
* - Should use kebab-case or camelCase
|
|
45
|
+
* - Should not contain spaces or special characters (except hyphens)
|
|
46
|
+
* - Should be descriptive and unique
|
|
47
|
+
*/
|
|
48
|
+
export declare function isValidPluginName(name: string): boolean;
|
|
49
|
+
//# sourceMappingURL=plugin-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-base.d.ts","sourceRoot":"","sources":["../../src/plugins/plugin-base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,CACzB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CACN,aAAa,EAAE,aAAa,EAC5B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC/B,IAAI,GACT,cAAc,CAahB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,cAAc,CAY5D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAsBvD"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extended DateTime interface with relative time methods
|
|
3
|
+
*/
|
|
4
|
+
declare module "../../core/datetime" {
|
|
5
|
+
interface DateTime {
|
|
6
|
+
/**
|
|
7
|
+
* Returns a human-readable string representing the time from now
|
|
8
|
+
* @returns Relative time string (e.g., "2 hours ago", "in 3 days")
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* dt.fromNow() // "2 hours ago"
|
|
13
|
+
* dt.fromNow() // "in 3 days"
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
fromNow(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Returns a human-readable string representing the time to now
|
|
19
|
+
* Opposite of fromNow()
|
|
20
|
+
* @returns Relative time string
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* dt.toNow() // "in 2 hours"
|
|
25
|
+
* dt.toNow() // "3 days ago"
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
toNow(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Returns a human-readable string representing the time from another DateTime
|
|
31
|
+
* @param other - DateTime instance to compare against
|
|
32
|
+
* @returns Relative time string
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* dt1.from(dt2) // "2 hours ago"
|
|
37
|
+
* dt1.from(dt2) // "in 3 days"
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
from(other: DateTime): string;
|
|
41
|
+
/**
|
|
42
|
+
* Returns a human-readable string representing the time to another DateTime
|
|
43
|
+
* Opposite of from()
|
|
44
|
+
* @param other - DateTime instance to compare against
|
|
45
|
+
* @returns Relative time string
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* dt1.to(dt2) // "in 2 hours"
|
|
50
|
+
* dt1.to(dt2) // "3 days ago"
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
to(other: DateTime): string;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Relative Time plugin for DateTime
|
|
58
|
+
* Adds methods for human-readable relative time formatting
|
|
59
|
+
*/
|
|
60
|
+
export declare const relativeTimePlugin: import("../..").DateTimePlugin;
|
|
61
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/relative-time/index.ts"],"names":[],"mappings":"AAiEA;;GAEG;AACH,OAAO,QAAQ,qBAAqB,CAAC;IAClC,UAAU,QAAQ;QACf;;;;;;;;;WASG;QACH,OAAO,IAAI,MAAM,CAAC;QAElB;;;;;;;;;;WAUG;QACH,KAAK,IAAI,MAAM,CAAC;QAEhB;;;;;;;;;;WAUG;QACH,IAAI,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAAC;QAE9B;;;;;;;;;;;WAWG;QACH,EAAE,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAAC;KAC9B;CACH;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,gCAwC9B,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extended DateTime interface with timezone methods
|
|
3
|
+
*/
|
|
4
|
+
declare module "../../core/datetime" {
|
|
5
|
+
interface DateTime {
|
|
6
|
+
/**
|
|
7
|
+
* Sets the timezone for this DateTime instance
|
|
8
|
+
* @param timezone - IANA timezone string (e.g., "America/New_York")
|
|
9
|
+
* @returns New DateTime instance with timezone set
|
|
10
|
+
*/
|
|
11
|
+
tz(timezone: string): DateTime;
|
|
12
|
+
/**
|
|
13
|
+
* Converts this DateTime to a different timezone
|
|
14
|
+
* @param timezone - IANA timezone string
|
|
15
|
+
* @returns New DateTime instance in the specified timezone
|
|
16
|
+
*/
|
|
17
|
+
toTimezone(timezone: string): DateTime;
|
|
18
|
+
/**
|
|
19
|
+
* Converts this DateTime to UTC timezone
|
|
20
|
+
* @returns New DateTime instance in UTC
|
|
21
|
+
*/
|
|
22
|
+
utc(): DateTime;
|
|
23
|
+
/**
|
|
24
|
+
* Converts this DateTime to local system timezone
|
|
25
|
+
* @returns New DateTime instance in local timezone
|
|
26
|
+
*/
|
|
27
|
+
local(): DateTime;
|
|
28
|
+
/**
|
|
29
|
+
* Gets the current timezone of this DateTime instance
|
|
30
|
+
* @returns IANA timezone string
|
|
31
|
+
*/
|
|
32
|
+
getTimezone(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Internal timezone storage
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
_timezone?: string;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Extended DateTimeClass interface with static timezone method
|
|
42
|
+
*/
|
|
43
|
+
declare module "../../types" {
|
|
44
|
+
interface DateTimeClass {
|
|
45
|
+
/**
|
|
46
|
+
* Creates a DateTime instance in a specific timezone
|
|
47
|
+
* @param input - Date input
|
|
48
|
+
* @param timezone - IANA timezone string
|
|
49
|
+
* @returns DateTime instance in the specified timezone
|
|
50
|
+
*/
|
|
51
|
+
tz(input: any, timezone: string): DateTime;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Timezone plugin for DateTime
|
|
56
|
+
* Adds timezone support using IANA timezone strings
|
|
57
|
+
*/
|
|
58
|
+
export declare const timezonePlugin: import("../..").DateTimePlugin;
|
|
59
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/timezone/index.ts"],"names":[],"mappings":"AA+BA;;GAEG;AACH,OAAO,QAAQ,qBAAqB,CAAC;IAClC,UAAU,QAAQ;QACf;;;;WAIG;QACH,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC;QAE/B;;;;WAIG;QACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC;QAEvC;;;WAGG;QACH,GAAG,IAAI,QAAQ,CAAC;QAEhB;;;WAGG;QACH,KAAK,IAAI,QAAQ,CAAC;QAElB;;;WAGG;QACH,WAAW,IAAI,MAAM,CAAC;QAEtB;;;WAGG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;KACrB;CACH;AAED;;GAEG;AACH,OAAO,QAAQ,aAAa,CAAC;IAC1B,UAAU,aAAa;QACpB;;;;;WAKG;QACH,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC;KAC7C;CACH;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,gCAwD1B,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Schema for time units
|
|
4
|
+
*/
|
|
5
|
+
export declare const TimeUnitSchema: z.ZodEnum<{
|
|
6
|
+
millisecond: "millisecond";
|
|
7
|
+
second: "second";
|
|
8
|
+
minute: "minute";
|
|
9
|
+
hour: "hour";
|
|
10
|
+
day: "day";
|
|
11
|
+
week: "week";
|
|
12
|
+
month: "month";
|
|
13
|
+
year: "year";
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Schema for DateTime input types
|
|
17
|
+
* Accepts Date, string, number, or DateTime instance
|
|
18
|
+
*/
|
|
19
|
+
export declare const DateInputSchema: z.ZodUnion<readonly [z.ZodDate, z.ZodString, z.ZodNumber, z.ZodCustom<import(".").DateTime, import(".").DateTime>]>;
|
|
20
|
+
/**
|
|
21
|
+
* Schema for DateTime configuration
|
|
22
|
+
*/
|
|
23
|
+
export declare const DateTimeConfigSchema: z.ZodObject<{
|
|
24
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
25
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
26
|
+
utc: z.ZodOptional<z.ZodBoolean>;
|
|
27
|
+
strict: z.ZodOptional<z.ZodBoolean>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
/**
|
|
30
|
+
* Schema for format options
|
|
31
|
+
*/
|
|
32
|
+
export declare const FormatOptionsSchema: z.ZodObject<{
|
|
33
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
34
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
/**
|
|
37
|
+
* Schema for parse options
|
|
38
|
+
*/
|
|
39
|
+
export declare const ParseOptionsSchema: z.ZodObject<{
|
|
40
|
+
strict: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
format: z.ZodOptional<z.ZodString>;
|
|
42
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
/**
|
|
45
|
+
* Schema for ISO 8601 date strings (full datetime with timezone)
|
|
46
|
+
* Matches: YYYY-MM-DDTHH:mm:ss.sssZ or YYYY-MM-DDTHH:mm:ss.sss±HH:mm
|
|
47
|
+
*/
|
|
48
|
+
export declare const ISODateSchema: z.ZodString;
|
|
49
|
+
/**
|
|
50
|
+
* Schema for ISO 8601 date-only strings
|
|
51
|
+
* Matches: YYYY-MM-DD
|
|
52
|
+
*/
|
|
53
|
+
export declare const ISODateOnlySchema: z.ZodString;
|
|
54
|
+
/**
|
|
55
|
+
* Schema for ISO 8601 time-only strings
|
|
56
|
+
* Matches: HH:mm:ss or HH:mm:ss.sss
|
|
57
|
+
*/
|
|
58
|
+
export declare const ISOTimeOnlySchema: z.ZodString;
|
|
59
|
+
/**
|
|
60
|
+
* Schema for plugin definition
|
|
61
|
+
*/
|
|
62
|
+
export declare const DateTimePluginSchema: z.ZodObject<{
|
|
63
|
+
name: z.ZodString;
|
|
64
|
+
install: z.ZodFunction<z.core.$ZodFunctionArgs, z.core.$ZodFunctionOut>;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;EASzB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,eAAe,qHAc1B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;iBAK/B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;iBAG9B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;iBAI7B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,aAAa,aAQtB,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,iBAAiB,aAE5B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,iBAAiB,aAKzB,CAAC;AAEN;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;iBAG/B,CAAC"}
|