@gobrand/tiempo 2.3.6 → 2.4.1
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/README.md +3 -3
- package/dist/browserTimezone.d.ts +22 -0
- package/dist/browserTimezone.d.ts.map +1 -0
- package/dist/browserTimezone.js +7 -0
- package/dist/browserTimezone.test.d.ts +2 -0
- package/dist/browserTimezone.test.d.ts.map +1 -0
- package/dist/chunk-BSV32PSO.js +17 -0
- package/dist/chunk-BSV32PSO.js.map +1 -0
- package/dist/{chunk-2MP3ESL7.js → chunk-DCJUK6EE.js} +1 -1
- package/dist/chunk-DCJUK6EE.js.map +1 -0
- package/dist/chunk-DFLGGK4F.js +30 -0
- package/dist/chunk-DFLGGK4F.js.map +1 -0
- package/dist/chunk-RQUZG65U.js +9 -0
- package/dist/chunk-RQUZG65U.js.map +1 -0
- package/dist/{chunk-XEDXPI5G.js → chunk-TDQXOSO3.js} +4 -4
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -21
- package/dist/intlFormatDistance.js +2 -2
- package/dist/toIso.d.ts +31 -0
- package/dist/toIso.d.ts.map +1 -0
- package/dist/toIso.js +7 -0
- package/dist/toIso.js.map +1 -0
- package/dist/toIso.test.d.ts +2 -0
- package/dist/toIso.test.d.ts.map +1 -0
- package/dist/toIso9075.d.ts +41 -0
- package/dist/toIso9075.d.ts.map +1 -0
- package/dist/toIso9075.js +7 -0
- package/dist/toIso9075.js.map +1 -0
- package/dist/toIso9075.test.d.ts +2 -0
- package/dist/toIso9075.test.d.ts.map +1 -0
- package/dist/toZonedTime.d.ts +27 -7
- package/dist/toZonedTime.d.ts.map +1 -1
- package/dist/toZonedTime.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2MP3ESL7.js.map +0 -1
- package/dist/chunk-DMKGJY4N.js +0 -13
- package/dist/chunk-DMKGJY4N.js.map +0 -1
- package/dist/toUtcString.d.ts +0 -22
- package/dist/toUtcString.d.ts.map +0 -1
- package/dist/toUtcString.js +0 -7
- package/dist/toUtcString.test.d.ts +0 -2
- package/dist/toUtcString.test.d.ts.map +0 -1
- /package/dist/{toUtcString.js.map → browserTimezone.js.map} +0 -0
- /package/dist/{chunk-XEDXPI5G.js.map → chunk-TDQXOSO3.js.map} +0 -0
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
- **Familiar API** - If you've used date-fns, you already know this
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
|
-
import { toZonedTime, addDays, format,
|
|
20
|
+
import { toZonedTime, addDays, format, toIso } from '@gobrand/tiempo';
|
|
21
21
|
|
|
22
22
|
// Backend sends UTC
|
|
23
23
|
const utc = "2025-03-09T07:00:00Z";
|
|
@@ -27,8 +27,8 @@ const userTime = toZonedTime(utc, "America/New_York");
|
|
|
27
27
|
const tomorrow = addDays(userTime, 1); // DST transition handled correctly
|
|
28
28
|
const display = format(tomorrow, "EEEE 'at' h:mm a"); // "Monday at 2:00 AM"
|
|
29
29
|
|
|
30
|
-
// Send back to backend as
|
|
31
|
-
const payload =
|
|
30
|
+
// Send back to backend as ISO 8601 string
|
|
31
|
+
const payload = toIso(tomorrow); // "2025-03-10T06:00:00Z"
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
## Install
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the browser/device timezone.
|
|
3
|
+
*
|
|
4
|
+
* Returns the IANA timezone identifier configured on the user's device.
|
|
5
|
+
* This is primarily useful in client-side code (browsers, React Native).
|
|
6
|
+
*
|
|
7
|
+
* **Warning:** On servers, this returns the server's configured timezone
|
|
8
|
+
* (often "UTC"), which is rarely what you want. For user-specific timezones
|
|
9
|
+
* on the server, retrieve the timezone from user preferences or request headers.
|
|
10
|
+
*
|
|
11
|
+
* @returns The IANA timezone identifier (e.g., "America/New_York", "Europe/London")
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { toZonedTime, browserTimezone } from '@gobrand/tiempo';
|
|
16
|
+
*
|
|
17
|
+
* // Convert UTC to the user's local timezone
|
|
18
|
+
* const userTime = toZonedTime("2025-01-20T20:00:00Z", browserTimezone());
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function browserTimezone(): string;
|
|
22
|
+
//# sourceMappingURL=browserTimezone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browserTimezone.d.ts","sourceRoot":"","sources":["../src/browserTimezone.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browserTimezone.test.d.ts","sourceRoot":"","sources":["../src/browserTimezone.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/toIso.ts
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
function toIso(input, options = {}) {
|
|
4
|
+
const { mode = "utc" } = options;
|
|
5
|
+
if (input instanceof Temporal.Instant) {
|
|
6
|
+
return input.toString();
|
|
7
|
+
}
|
|
8
|
+
if (mode === "offset") {
|
|
9
|
+
return input.toString({ timeZoneName: "never" });
|
|
10
|
+
}
|
|
11
|
+
return input.toInstant().toString();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
toIso
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=chunk-BSV32PSO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/toIso.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\nexport type IsoMode = 'utc' | 'offset';\n\nexport interface ToIsoOptions {\n /**\n * Output mode for time zone designator.\n * - 'utc' (default): UTC time with Z suffix\n * - 'offset': local time with offset suffix\n */\n mode?: IsoMode;\n}\n\n/**\n * Convert a Temporal.Instant to a UTC ISO 8601 string.\n */\nexport function toIso(input: Temporal.Instant): string;\n\n/**\n * Convert a Temporal.ZonedDateTime to an ISO 8601 string.\n *\n * @param input - A Temporal.ZonedDateTime\n * @param options - Output options\n *\n * @example\n * ```typescript\n * const zoned = Temporal.ZonedDateTime.from(\"2025-01-20T15:00:00-05:00[America/New_York]\");\n *\n * toIso(zoned); // \"2025-01-20T20:00:00Z\"\n * toIso(zoned, { mode: 'utc' }); // \"2025-01-20T20:00:00Z\"\n * toIso(zoned, { mode: 'offset' }); // \"2025-01-20T15:00:00-05:00\"\n * ```\n */\nexport function toIso(\n input: Temporal.ZonedDateTime,\n options?: ToIsoOptions\n): string;\n\nexport function toIso(\n input: Temporal.Instant | Temporal.ZonedDateTime,\n options: ToIsoOptions = {}\n): string {\n const { mode = 'utc' } = options;\n\n if (input instanceof Temporal.Instant) {\n return input.toString();\n }\n\n if (mode === 'offset') {\n return input.toString({ timeZoneName: 'never' });\n }\n\n return input.toInstant().toString();\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAsClB,SAAS,MACd,OACA,UAAwB,CAAC,GACjB;AACR,QAAM,EAAE,OAAO,MAAM,IAAI;AAEzB,MAAI,iBAAiB,SAAS,SAAS;AACrC,WAAO,MAAM,SAAS;AAAA,EACxB;AAEA,MAAI,SAAS,UAAU;AACrB,WAAO,MAAM,SAAS,EAAE,cAAc,QAAQ,CAAC;AAAA,EACjD;AAEA,SAAO,MAAM,UAAU,EAAE,SAAS;AACpC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/toZonedTime.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\n/**\n * IANA timezone identifier or \"UTC\".\n *\n * Common timezones:\n * - \"UTC\" - Coordinated Universal Time\n * - \"America/New_York\" - US Eastern\n * - \"America/Los_Angeles\" - US Pacific\n * - \"Europe/London\" - UK\n * - \"Europe/Paris\" - Central European\n * - \"Asia/Tokyo\" - Japan\n * - \"Asia/Shanghai\" - China\n */\nexport type Timezone = 'UTC' | (string & {});\n\n/**\n * Convert a UTC ISO string, Date, Instant, or ZonedDateTime to a ZonedDateTime in the specified timezone.\n *\n * @param input - A UTC ISO 8601 string, Date object, Temporal.Instant, or Temporal.ZonedDateTime\n * @param timezone - IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\") or \"UTC\"\n * @returns A Temporal.ZonedDateTime in the specified timezone\n *\n * @example\n * ```typescript\n * import { toZonedTime, browserTimezone } from '@gobrand/tiempo';\n *\n * // Server-side: Convert to UTC\n * const utcTime = toZonedTime(\"2025-01-20T20:00:00Z\", \"UTC\");\n *\n * // Server-side: Convert to user's timezone (from DB/preferences)\n * const userTime = toZonedTime(\"2025-01-20T20:00:00Z\", user.timezone);\n *\n * // Client-side: Convert to browser's timezone\n * const localTime = toZonedTime(\"2025-01-20T20:00:00Z\", browserTimezone());\n *\n * // From Date (e.g., from Drizzle ORM)\n * const date = new Date(\"2025-01-20T20:00:00.000Z\");\n * const zoned = toZonedTime(date, \"America/New_York\");\n *\n * // From Instant\n * const instant = Temporal.Instant.from(\"2025-01-20T20:00:00Z\");\n * const zoned = toZonedTime(instant, \"Asia/Tokyo\");\n *\n * // From ZonedDateTime (convert to different timezone)\n * const nyTime = Temporal.ZonedDateTime.from(\"2025-01-20T15:00:00-05:00[America/New_York]\");\n * const tokyoTime = toZonedTime(nyTime, \"Asia/Tokyo\");\n * ```\n */\nexport function toZonedTime(\n input: string | Date | Temporal.Instant | Temporal.ZonedDateTime,\n timezone: Timezone\n): Temporal.ZonedDateTime {\n if (typeof input === 'string') {\n return Temporal.Instant.from(input).toZonedDateTimeISO(timezone);\n }\n\n if (input instanceof Date) {\n return Temporal.Instant.from(input.toISOString()).toZonedDateTimeISO(timezone);\n }\n\n if (input instanceof Temporal.Instant) {\n return input.toZonedDateTimeISO(timezone);\n }\n\n return input.toInstant().toZonedDateTimeISO(timezone);\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAiDlB,SAAS,YACd,OACA,UACwB;AACxB,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,SAAS,QAAQ,KAAK,KAAK,EAAE,mBAAmB,QAAQ;AAAA,EACjE;AAEA,MAAI,iBAAiB,MAAM;AACzB,WAAO,SAAS,QAAQ,KAAK,MAAM,YAAY,CAAC,EAAE,mBAAmB,QAAQ;AAAA,EAC/E;AAEA,MAAI,iBAAiB,SAAS,SAAS;AACrC,WAAO,MAAM,mBAAmB,QAAQ;AAAA,EAC1C;AAEA,SAAO,MAAM,UAAU,EAAE,mBAAmB,QAAQ;AACtD;","names":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/toIso9075.ts
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
function toIso9075(input, options = {}) {
|
|
4
|
+
const { mode = "utc", representation = "complete" } = options;
|
|
5
|
+
let zdt;
|
|
6
|
+
if (input instanceof Temporal.Instant) {
|
|
7
|
+
zdt = input.toZonedDateTimeISO("UTC");
|
|
8
|
+
} else {
|
|
9
|
+
zdt = mode === "utc" ? input.toInstant().toZonedDateTimeISO("UTC") : input;
|
|
10
|
+
}
|
|
11
|
+
const year = zdt.year;
|
|
12
|
+
const month = zdt.month;
|
|
13
|
+
const day = zdt.day;
|
|
14
|
+
const hour = zdt.hour;
|
|
15
|
+
const minute = zdt.minute;
|
|
16
|
+
const second = zdt.second;
|
|
17
|
+
const datePart = `${year}-${pad(month)}-${pad(day)}`;
|
|
18
|
+
const timePart = `${pad(hour)}:${pad(minute)}:${pad(second)}`;
|
|
19
|
+
if (representation === "date") return datePart;
|
|
20
|
+
if (representation === "time") return timePart;
|
|
21
|
+
return `${datePart} ${timePart}`;
|
|
22
|
+
}
|
|
23
|
+
function pad(n) {
|
|
24
|
+
return n.toString().padStart(2, "0");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
toIso9075
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=chunk-DFLGGK4F.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/toIso9075.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\nexport type Iso9075Mode = 'utc' | 'local';\nexport type Iso9075Representation = 'complete' | 'date' | 'time';\n\nexport interface ToIso9075Options {\n /**\n * Which time to output.\n * - 'utc' (default): convert to UTC before formatting\n * - 'local': use the local time of the ZonedDateTime\n */\n mode?: Iso9075Mode;\n /**\n * What to include in the output.\n * - 'complete' (default): date and time (2019-09-18 19:00:52)\n * - 'date': date only (2019-09-18)\n * - 'time': time only (19:00:52)\n */\n representation?: Iso9075Representation;\n}\n\n/**\n * Convert a Temporal.Instant to an ISO 9075 (SQL) formatted string in UTC.\n */\nexport function toIso9075(\n input: Temporal.Instant,\n options?: Omit<ToIso9075Options, 'mode'>\n): string;\n\n/**\n * Convert a Temporal.ZonedDateTime to an ISO 9075 (SQL) formatted string.\n *\n * @param input - A Temporal.ZonedDateTime\n * @param options - Format options\n *\n * @example\n * ```typescript\n * const zoned = Temporal.ZonedDateTime.from(\"2025-01-20T15:00:00-05:00[America/New_York]\");\n *\n * toIso9075(zoned); // \"2025-01-20 20:00:00\" (UTC, default)\n * toIso9075(zoned, { mode: 'utc' }); // \"2025-01-20 20:00:00\"\n * toIso9075(zoned, { mode: 'local' }); // \"2025-01-20 15:00:00\"\n * toIso9075(zoned, { representation: 'date' }); // \"2025-01-20\"\n * toIso9075(zoned, { representation: 'time' }); // \"20:00:00\"\n * ```\n */\nexport function toIso9075(\n input: Temporal.ZonedDateTime,\n options?: ToIso9075Options\n): string;\n\nexport function toIso9075(\n input: Temporal.Instant | Temporal.ZonedDateTime,\n options: ToIso9075Options = {}\n): string {\n const { mode = 'utc', representation = 'complete' } = options;\n\n let zdt: Temporal.ZonedDateTime;\n\n if (input instanceof Temporal.Instant) {\n zdt = input.toZonedDateTimeISO('UTC');\n } else {\n // ZonedDateTime: apply mode\n zdt = mode === 'utc' ? input.toInstant().toZonedDateTimeISO('UTC') : input;\n }\n\n const year = zdt.year;\n const month = zdt.month;\n const day = zdt.day;\n const hour = zdt.hour;\n const minute = zdt.minute;\n const second = zdt.second;\n\n const datePart = `${year}-${pad(month)}-${pad(day)}`;\n const timePart = `${pad(hour)}:${pad(minute)}:${pad(second)}`;\n\n if (representation === 'date') return datePart;\n if (representation === 'time') return timePart;\n return `${datePart} ${timePart}`;\n}\n\nfunction pad(n: number): string {\n return n.toString().padStart(2, '0');\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAmDlB,SAAS,UACd,OACA,UAA4B,CAAC,GACrB;AACR,QAAM,EAAE,OAAO,OAAO,iBAAiB,WAAW,IAAI;AAEtD,MAAI;AAEJ,MAAI,iBAAiB,SAAS,SAAS;AACrC,UAAM,MAAM,mBAAmB,KAAK;AAAA,EACtC,OAAO;AAEL,UAAM,SAAS,QAAQ,MAAM,UAAU,EAAE,mBAAmB,KAAK,IAAI;AAAA,EACvE;AAEA,QAAM,OAAO,IAAI;AACjB,QAAM,QAAQ,IAAI;AAClB,QAAM,MAAM,IAAI;AAChB,QAAM,OAAO,IAAI;AACjB,QAAM,SAAS,IAAI;AACnB,QAAM,SAAS,IAAI;AAEnB,QAAM,WAAW,GAAG,IAAI,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,GAAG,CAAC;AAClD,QAAM,WAAW,GAAG,IAAI,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC;AAE3D,MAAI,mBAAmB,OAAQ,QAAO;AACtC,MAAI,mBAAmB,OAAQ,QAAO;AACtC,SAAO,GAAG,QAAQ,IAAI,QAAQ;AAChC;AAEA,SAAS,IAAI,GAAmB;AAC9B,SAAO,EAAE,SAAS,EAAE,SAAS,GAAG,GAAG;AACrC;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/browserTimezone.ts"],"sourcesContent":["/**\n * Get the browser/device timezone.\n *\n * Returns the IANA timezone identifier configured on the user's device.\n * This is primarily useful in client-side code (browsers, React Native).\n *\n * **Warning:** On servers, this returns the server's configured timezone\n * (often \"UTC\"), which is rarely what you want. For user-specific timezones\n * on the server, retrieve the timezone from user preferences or request headers.\n *\n * @returns The IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\")\n *\n * @example\n * ```typescript\n * import { toZonedTime, browserTimezone } from '@gobrand/tiempo';\n *\n * // Convert UTC to the user's local timezone\n * const userTime = toZonedTime(\"2025-01-20T20:00:00Z\", browserTimezone());\n * ```\n */\nexport function browserTimezone(): string {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n}\n"],"mappings":";AAoBO,SAAS,kBAA0B;AACxC,SAAO,KAAK,eAAe,EAAE,gBAAgB,EAAE;AACjD;","names":[]}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
differenceInMonths
|
|
3
|
+
} from "./chunk-BIAPE4MR.js";
|
|
1
4
|
import {
|
|
2
5
|
differenceInSeconds
|
|
3
6
|
} from "./chunk-ZHRMURYP.js";
|
|
@@ -16,9 +19,6 @@ import {
|
|
|
16
19
|
import {
|
|
17
20
|
differenceInMinutes
|
|
18
21
|
} from "./chunk-RJY62CDU.js";
|
|
19
|
-
import {
|
|
20
|
-
differenceInMonths
|
|
21
|
-
} from "./chunk-BIAPE4MR.js";
|
|
22
22
|
import {
|
|
23
23
|
normalizeTemporalInput
|
|
24
24
|
} from "./chunk-MJSZNWCV.js";
|
|
@@ -91,4 +91,4 @@ function intlFormatDistance(laterDate, earlierDate, options) {
|
|
|
91
91
|
export {
|
|
92
92
|
intlFormatDistance
|
|
93
93
|
};
|
|
94
|
-
//# sourceMappingURL=chunk-
|
|
94
|
+
//# sourceMappingURL=chunk-TDQXOSO3.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export { toZonedTime } from './toZonedTime';
|
|
1
|
+
export { toZonedTime, type Timezone } from './toZonedTime';
|
|
2
|
+
export { browserTimezone } from './browserTimezone';
|
|
2
3
|
export { toUtc } from './toUtc';
|
|
3
|
-
export {
|
|
4
|
+
export { toIso, type IsoMode, type ToIsoOptions } from './toIso';
|
|
5
|
+
export { toIso9075, type ToIso9075Options, type Iso9075Representation, type Iso9075Mode, } from './toIso9075';
|
|
4
6
|
export { toDate } from './toDate';
|
|
5
7
|
export { format, type FormatOptions } from './format';
|
|
6
8
|
export { formatPlainDate, type FormatPlainDateOptions } from './formatPlainDate';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
toIso
|
|
3
|
+
} from "./chunk-BSV32PSO.js";
|
|
4
|
+
import {
|
|
5
|
+
toIso9075
|
|
6
|
+
} from "./chunk-DFLGGK4F.js";
|
|
7
|
+
import {
|
|
8
|
+
toUtc
|
|
9
|
+
} from "./chunk-BW5SFCKS.js";
|
|
4
10
|
import {
|
|
5
11
|
toZonedTime
|
|
6
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-DCJUK6EE.js";
|
|
7
13
|
import {
|
|
8
14
|
today
|
|
9
15
|
} from "./chunk-67QHALIG.js";
|
|
16
|
+
import {
|
|
17
|
+
subMinutes
|
|
18
|
+
} from "./chunk-J6G2I2TU.js";
|
|
10
19
|
import {
|
|
11
20
|
subMonths
|
|
12
21
|
} from "./chunk-52NEOY34.js";
|
|
@@ -26,8 +35,8 @@ import {
|
|
|
26
35
|
toDate
|
|
27
36
|
} from "./chunk-TGKWBQ7L.js";
|
|
28
37
|
import {
|
|
29
|
-
|
|
30
|
-
} from "./chunk-
|
|
38
|
+
startOfDay
|
|
39
|
+
} from "./chunk-TW5EV3DH.js";
|
|
31
40
|
import {
|
|
32
41
|
startOfMonth
|
|
33
42
|
} from "./chunk-TU2UNOOW.js";
|
|
@@ -50,8 +59,8 @@ import {
|
|
|
50
59
|
subMilliseconds
|
|
51
60
|
} from "./chunk-HDBH7RTY.js";
|
|
52
61
|
import {
|
|
53
|
-
|
|
54
|
-
} from "./chunk-
|
|
62
|
+
isSameMinute
|
|
63
|
+
} from "./chunk-LDO6PRNJ.js";
|
|
55
64
|
import {
|
|
56
65
|
isSameMonth
|
|
57
66
|
} from "./chunk-ADQTZVMH.js";
|
|
@@ -74,8 +83,8 @@ import {
|
|
|
74
83
|
simpleFormat
|
|
75
84
|
} from "./chunk-GQBO2UXH.js";
|
|
76
85
|
import {
|
|
77
|
-
|
|
78
|
-
} from "./chunk-
|
|
86
|
+
isPast
|
|
87
|
+
} from "./chunk-2H4KLXGL.js";
|
|
79
88
|
import {
|
|
80
89
|
isPlainDateAfter
|
|
81
90
|
} from "./chunk-BPZ7BRJW.js";
|
|
@@ -98,8 +107,8 @@ import {
|
|
|
98
107
|
isSameMillisecond
|
|
99
108
|
} from "./chunk-ISHZRFVN.js";
|
|
100
109
|
import {
|
|
101
|
-
|
|
102
|
-
} from "./chunk-
|
|
110
|
+
endOfYear
|
|
111
|
+
} from "./chunk-XDVUGTUV.js";
|
|
103
112
|
import {
|
|
104
113
|
format
|
|
105
114
|
} from "./chunk-2G5RJGPR.js";
|
|
@@ -108,7 +117,7 @@ import {
|
|
|
108
117
|
} from "./chunk-3A6X6WV5.js";
|
|
109
118
|
import {
|
|
110
119
|
intlFormatDistance
|
|
111
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-TDQXOSO3.js";
|
|
112
121
|
import {
|
|
113
122
|
isAfter
|
|
114
123
|
} from "./chunk-BBNNR2QH.js";
|
|
@@ -119,8 +128,8 @@ import {
|
|
|
119
128
|
isFuture
|
|
120
129
|
} from "./chunk-R5XN76EV.js";
|
|
121
130
|
import {
|
|
122
|
-
|
|
123
|
-
} from "./chunk-
|
|
131
|
+
differenceInMonths
|
|
132
|
+
} from "./chunk-BIAPE4MR.js";
|
|
124
133
|
import {
|
|
125
134
|
differenceInNanoseconds
|
|
126
135
|
} from "./chunk-OABS374T.js";
|
|
@@ -142,9 +151,6 @@ import {
|
|
|
142
151
|
import {
|
|
143
152
|
endOfWeek
|
|
144
153
|
} from "./chunk-XVJJR7H6.js";
|
|
145
|
-
import {
|
|
146
|
-
endOfYear
|
|
147
|
-
} from "./chunk-XDVUGTUV.js";
|
|
148
154
|
import "./chunk-AVGNRINZ.js";
|
|
149
155
|
import {
|
|
150
156
|
addWeeks
|
|
@@ -152,6 +158,9 @@ import {
|
|
|
152
158
|
import {
|
|
153
159
|
addYears
|
|
154
160
|
} from "./chunk-Q2F3HEXB.js";
|
|
161
|
+
import {
|
|
162
|
+
browserTimezone
|
|
163
|
+
} from "./chunk-RQUZG65U.js";
|
|
155
164
|
import {
|
|
156
165
|
differenceInDays
|
|
157
166
|
} from "./chunk-6IP245MS.js";
|
|
@@ -167,9 +176,6 @@ import {
|
|
|
167
176
|
import {
|
|
168
177
|
differenceInMinutes
|
|
169
178
|
} from "./chunk-RJY62CDU.js";
|
|
170
|
-
import {
|
|
171
|
-
differenceInMonths
|
|
172
|
-
} from "./chunk-BIAPE4MR.js";
|
|
173
179
|
import {
|
|
174
180
|
addDays
|
|
175
181
|
} from "./chunk-L4SVABDH.js";
|
|
@@ -206,6 +212,7 @@ export {
|
|
|
206
212
|
addSeconds,
|
|
207
213
|
addWeeks,
|
|
208
214
|
addYears,
|
|
215
|
+
browserTimezone,
|
|
209
216
|
differenceInDays,
|
|
210
217
|
differenceInHours,
|
|
211
218
|
differenceInMicroseconds,
|
|
@@ -257,8 +264,9 @@ export {
|
|
|
257
264
|
subWeeks,
|
|
258
265
|
subYears,
|
|
259
266
|
toDate,
|
|
267
|
+
toIso,
|
|
268
|
+
toIso9075,
|
|
260
269
|
toUtc,
|
|
261
|
-
toUtcString,
|
|
262
270
|
toZonedTime,
|
|
263
271
|
today
|
|
264
272
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
intlFormatDistance
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TDQXOSO3.js";
|
|
4
|
+
import "./chunk-BIAPE4MR.js";
|
|
4
5
|
import "./chunk-ZHRMURYP.js";
|
|
5
6
|
import "./chunk-PVAOUYXF.js";
|
|
6
7
|
import "./chunk-CHW2EN2O.js";
|
|
7
8
|
import "./chunk-6IP245MS.js";
|
|
8
9
|
import "./chunk-PIDXROVB.js";
|
|
9
10
|
import "./chunk-RJY62CDU.js";
|
|
10
|
-
import "./chunk-BIAPE4MR.js";
|
|
11
11
|
import "./chunk-MJSZNWCV.js";
|
|
12
12
|
export {
|
|
13
13
|
intlFormatDistance
|
package/dist/toIso.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
export type IsoMode = 'utc' | 'offset';
|
|
3
|
+
export interface ToIsoOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Output mode for time zone designator.
|
|
6
|
+
* - 'utc' (default): UTC time with Z suffix
|
|
7
|
+
* - 'offset': local time with offset suffix
|
|
8
|
+
*/
|
|
9
|
+
mode?: IsoMode;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Convert a Temporal.Instant to a UTC ISO 8601 string.
|
|
13
|
+
*/
|
|
14
|
+
export declare function toIso(input: Temporal.Instant): string;
|
|
15
|
+
/**
|
|
16
|
+
* Convert a Temporal.ZonedDateTime to an ISO 8601 string.
|
|
17
|
+
*
|
|
18
|
+
* @param input - A Temporal.ZonedDateTime
|
|
19
|
+
* @param options - Output options
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const zoned = Temporal.ZonedDateTime.from("2025-01-20T15:00:00-05:00[America/New_York]");
|
|
24
|
+
*
|
|
25
|
+
* toIso(zoned); // "2025-01-20T20:00:00Z"
|
|
26
|
+
* toIso(zoned, { mode: 'utc' }); // "2025-01-20T20:00:00Z"
|
|
27
|
+
* toIso(zoned, { mode: 'offset' }); // "2025-01-20T15:00:00-05:00"
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function toIso(input: Temporal.ZonedDateTime, options?: ToIsoOptions): string;
|
|
31
|
+
//# sourceMappingURL=toIso.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toIso.d.ts","sourceRoot":"","sources":["../src/toIso.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEvC,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC;AAEvD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,CACnB,KAAK,EAAE,QAAQ,CAAC,aAAa,EAC7B,OAAO,CAAC,EAAE,YAAY,GACrB,MAAM,CAAC"}
|
package/dist/toIso.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toIso.test.d.ts","sourceRoot":"","sources":["../src/toIso.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
export type Iso9075Mode = 'utc' | 'local';
|
|
3
|
+
export type Iso9075Representation = 'complete' | 'date' | 'time';
|
|
4
|
+
export interface ToIso9075Options {
|
|
5
|
+
/**
|
|
6
|
+
* Which time to output.
|
|
7
|
+
* - 'utc' (default): convert to UTC before formatting
|
|
8
|
+
* - 'local': use the local time of the ZonedDateTime
|
|
9
|
+
*/
|
|
10
|
+
mode?: Iso9075Mode;
|
|
11
|
+
/**
|
|
12
|
+
* What to include in the output.
|
|
13
|
+
* - 'complete' (default): date and time (2019-09-18 19:00:52)
|
|
14
|
+
* - 'date': date only (2019-09-18)
|
|
15
|
+
* - 'time': time only (19:00:52)
|
|
16
|
+
*/
|
|
17
|
+
representation?: Iso9075Representation;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Convert a Temporal.Instant to an ISO 9075 (SQL) formatted string in UTC.
|
|
21
|
+
*/
|
|
22
|
+
export declare function toIso9075(input: Temporal.Instant, options?: Omit<ToIso9075Options, 'mode'>): string;
|
|
23
|
+
/**
|
|
24
|
+
* Convert a Temporal.ZonedDateTime to an ISO 9075 (SQL) formatted string.
|
|
25
|
+
*
|
|
26
|
+
* @param input - A Temporal.ZonedDateTime
|
|
27
|
+
* @param options - Format options
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const zoned = Temporal.ZonedDateTime.from("2025-01-20T15:00:00-05:00[America/New_York]");
|
|
32
|
+
*
|
|
33
|
+
* toIso9075(zoned); // "2025-01-20 20:00:00" (UTC, default)
|
|
34
|
+
* toIso9075(zoned, { mode: 'utc' }); // "2025-01-20 20:00:00"
|
|
35
|
+
* toIso9075(zoned, { mode: 'local' }); // "2025-01-20 15:00:00"
|
|
36
|
+
* toIso9075(zoned, { representation: 'date' }); // "2025-01-20"
|
|
37
|
+
* toIso9075(zoned, { representation: 'time' }); // "20:00:00"
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function toIso9075(input: Temporal.ZonedDateTime, options?: ToIso9075Options): string;
|
|
41
|
+
//# sourceMappingURL=toIso9075.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toIso9075.d.ts","sourceRoot":"","sources":["../src/toIso9075.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,OAAO,CAAC;AAC1C,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAEjE,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,qBAAqB,CAAC;CACxC;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,QAAQ,CAAC,OAAO,EACvB,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,GACvC,MAAM,CAAC;AAEV;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,QAAQ,CAAC,aAAa,EAC7B,OAAO,CAAC,EAAE,gBAAgB,GACzB,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toIso9075.test.d.ts","sourceRoot":"","sources":["../src/toIso9075.test.ts"],"names":[],"mappings":""}
|
package/dist/toZonedTime.d.ts
CHANGED
|
@@ -1,29 +1,49 @@
|
|
|
1
1
|
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
/**
|
|
3
|
+
* IANA timezone identifier or "UTC".
|
|
4
|
+
*
|
|
5
|
+
* Common timezones:
|
|
6
|
+
* - "UTC" - Coordinated Universal Time
|
|
7
|
+
* - "America/New_York" - US Eastern
|
|
8
|
+
* - "America/Los_Angeles" - US Pacific
|
|
9
|
+
* - "Europe/London" - UK
|
|
10
|
+
* - "Europe/Paris" - Central European
|
|
11
|
+
* - "Asia/Tokyo" - Japan
|
|
12
|
+
* - "Asia/Shanghai" - China
|
|
13
|
+
*/
|
|
14
|
+
export type Timezone = 'UTC' | (string & {});
|
|
2
15
|
/**
|
|
3
16
|
* Convert a UTC ISO string, Date, Instant, or ZonedDateTime to a ZonedDateTime in the specified timezone.
|
|
4
17
|
*
|
|
5
18
|
* @param input - A UTC ISO 8601 string, Date object, Temporal.Instant, or Temporal.ZonedDateTime
|
|
6
|
-
* @param timezone - IANA timezone identifier (e.g., "America/New_York", "Europe/London")
|
|
19
|
+
* @param timezone - IANA timezone identifier (e.g., "America/New_York", "Europe/London") or "UTC"
|
|
7
20
|
* @returns A Temporal.ZonedDateTime in the specified timezone
|
|
8
21
|
*
|
|
9
22
|
* @example
|
|
10
23
|
* ```typescript
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* //
|
|
24
|
+
* import { toZonedTime, browserTimezone } from '@gobrand/tiempo';
|
|
25
|
+
*
|
|
26
|
+
* // Server-side: Convert to UTC
|
|
27
|
+
* const utcTime = toZonedTime("2025-01-20T20:00:00Z", "UTC");
|
|
28
|
+
*
|
|
29
|
+
* // Server-side: Convert to user's timezone (from DB/preferences)
|
|
30
|
+
* const userTime = toZonedTime("2025-01-20T20:00:00Z", user.timezone);
|
|
31
|
+
*
|
|
32
|
+
* // Client-side: Convert to browser's timezone
|
|
33
|
+
* const localTime = toZonedTime("2025-01-20T20:00:00Z", browserTimezone());
|
|
14
34
|
*
|
|
15
35
|
* // From Date (e.g., from Drizzle ORM)
|
|
16
36
|
* const date = new Date("2025-01-20T20:00:00.000Z");
|
|
17
|
-
* const
|
|
37
|
+
* const zoned = toZonedTime(date, "America/New_York");
|
|
18
38
|
*
|
|
19
39
|
* // From Instant
|
|
20
40
|
* const instant = Temporal.Instant.from("2025-01-20T20:00:00Z");
|
|
21
|
-
* const
|
|
41
|
+
* const zoned = toZonedTime(instant, "Asia/Tokyo");
|
|
22
42
|
*
|
|
23
43
|
* // From ZonedDateTime (convert to different timezone)
|
|
24
44
|
* const nyTime = Temporal.ZonedDateTime.from("2025-01-20T15:00:00-05:00[America/New_York]");
|
|
25
45
|
* const tokyoTime = toZonedTime(nyTime, "Asia/Tokyo");
|
|
26
46
|
* ```
|
|
27
47
|
*/
|
|
28
|
-
export declare function toZonedTime(input: string | Date | Temporal.Instant | Temporal.ZonedDateTime, timezone:
|
|
48
|
+
export declare function toZonedTime(input: string | Date | Temporal.Instant | Temporal.ZonedDateTime, timezone: Timezone): Temporal.ZonedDateTime;
|
|
29
49
|
//# sourceMappingURL=toZonedTime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toZonedTime.d.ts","sourceRoot":"","sources":["../src/toZonedTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD
|
|
1
|
+
{"version":3,"file":"toZonedTime.d.ts","sourceRoot":"","sources":["../src/toZonedTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,EAChE,QAAQ,EAAE,QAAQ,GACjB,QAAQ,CAAC,aAAa,CAcxB"}
|
package/dist/toZonedTime.js
CHANGED
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/toZonedTime.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\n/**\n * Convert a UTC ISO string, Date, Instant, or ZonedDateTime to a ZonedDateTime in the specified timezone.\n *\n * @param input - A UTC ISO 8601 string, Date object, Temporal.Instant, or Temporal.ZonedDateTime\n * @param timezone - IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\")\n * @returns A Temporal.ZonedDateTime in the specified timezone\n *\n * @example\n * ```typescript\n * // From ISO string\n * const zoned = toZonedTime(\"2025-01-20T20:00:00.000Z\", \"America/New_York\");\n * // zoned.hour === 15 (3 PM in New York)\n *\n * // From Date (e.g., from Drizzle ORM)\n * const date = new Date(\"2025-01-20T20:00:00.000Z\");\n * const zoned2 = toZonedTime(date, \"America/New_York\");\n *\n * // From Instant\n * const instant = Temporal.Instant.from(\"2025-01-20T20:00:00Z\");\n * const zoned3 = toZonedTime(instant, \"Asia/Tokyo\");\n *\n * // From ZonedDateTime (convert to different timezone)\n * const nyTime = Temporal.ZonedDateTime.from(\"2025-01-20T15:00:00-05:00[America/New_York]\");\n * const tokyoTime = toZonedTime(nyTime, \"Asia/Tokyo\");\n * ```\n */\nexport function toZonedTime(\n input: string | Date | Temporal.Instant | Temporal.ZonedDateTime,\n timezone: string\n): Temporal.ZonedDateTime {\n if (typeof input === 'string') {\n return Temporal.Instant.from(input).toZonedDateTimeISO(timezone);\n }\n\n if (input instanceof Date) {\n return Temporal.Instant.from(input.toISOString()).toZonedDateTimeISO(timezone);\n }\n\n if (input instanceof Temporal.Instant) {\n return input.toZonedDateTimeISO(timezone);\n }\n\n return input.toInstant().toZonedDateTimeISO(timezone);\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AA4BlB,SAAS,YACd,OACA,UACwB;AACxB,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,SAAS,QAAQ,KAAK,KAAK,EAAE,mBAAmB,QAAQ;AAAA,EACjE;AAEA,MAAI,iBAAiB,MAAM;AACzB,WAAO,SAAS,QAAQ,KAAK,MAAM,YAAY,CAAC,EAAE,mBAAmB,QAAQ;AAAA,EAC/E;AAEA,MAAI,iBAAiB,SAAS,SAAS;AACrC,WAAO,MAAM,mBAAmB,QAAQ;AAAA,EAC1C;AAEA,SAAO,MAAM,UAAU,EAAE,mBAAmB,QAAQ;AACtD;","names":[]}
|
package/dist/chunk-DMKGJY4N.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// src/toUtcString.ts
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
function toUtcString(input) {
|
|
4
|
-
if (input instanceof Temporal.Instant) {
|
|
5
|
-
return input.toString();
|
|
6
|
-
}
|
|
7
|
-
return input.toInstant().toString();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
toUtcString
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=chunk-DMKGJY4N.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/toUtcString.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\n/**\n * Convert a Temporal.Instant or ZonedDateTime to a UTC ISO 8601 string.\n *\n * @param input - A Temporal.Instant or Temporal.ZonedDateTime\n * @returns A UTC ISO 8601 string representation\n *\n * @example\n * ```typescript\n * // From ZonedDateTime\n * const zoned = Temporal.ZonedDateTime.from(\"2025-01-20T15:00:00-05:00[America/New_York]\");\n * const utcString = toUtcString(zoned);\n * // utcString === \"2025-01-20T20:00:00Z\"\n *\n * // From Instant\n * const instant = Temporal.Instant.from(\"2025-01-20T20:00:00Z\");\n * const utcString2 = toUtcString(instant);\n * // utcString2 === \"2025-01-20T20:00:00Z\"\n * ```\n */\nexport function toUtcString(\n input: Temporal.Instant | Temporal.ZonedDateTime\n): string {\n if (input instanceof Temporal.Instant) {\n return input.toString();\n }\n\n return input.toInstant().toString();\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAqBlB,SAAS,YACd,OACQ;AACR,MAAI,iBAAiB,SAAS,SAAS;AACrC,WAAO,MAAM,SAAS;AAAA,EACxB;AAEA,SAAO,MAAM,UAAU,EAAE,SAAS;AACpC;","names":[]}
|
package/dist/toUtcString.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
-
/**
|
|
3
|
-
* Convert a Temporal.Instant or ZonedDateTime to a UTC ISO 8601 string.
|
|
4
|
-
*
|
|
5
|
-
* @param input - A Temporal.Instant or Temporal.ZonedDateTime
|
|
6
|
-
* @returns A UTC ISO 8601 string representation
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* // From ZonedDateTime
|
|
11
|
-
* const zoned = Temporal.ZonedDateTime.from("2025-01-20T15:00:00-05:00[America/New_York]");
|
|
12
|
-
* const utcString = toUtcString(zoned);
|
|
13
|
-
* // utcString === "2025-01-20T20:00:00Z"
|
|
14
|
-
*
|
|
15
|
-
* // From Instant
|
|
16
|
-
* const instant = Temporal.Instant.from("2025-01-20T20:00:00Z");
|
|
17
|
-
* const utcString2 = toUtcString(instant);
|
|
18
|
-
* // utcString2 === "2025-01-20T20:00:00Z"
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export declare function toUtcString(input: Temporal.Instant | Temporal.ZonedDateTime): string;
|
|
22
|
-
//# sourceMappingURL=toUtcString.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toUtcString.d.ts","sourceRoot":"","sources":["../src/toUtcString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,GAC/C,MAAM,CAMR"}
|
package/dist/toUtcString.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toUtcString.test.d.ts","sourceRoot":"","sources":["../src/toUtcString.test.ts"],"names":[],"mappings":""}
|
|
File without changes
|
|
File without changes
|