@gobrand/tiempo 2.3.6 → 2.4.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.
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, toUtcString } from '@gobrand/tiempo';
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 UTC
31
- const payload = toUtcString(tomorrow); // "2025-03-10T06:00:00Z"
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,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,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":[]}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { toZonedTime } from './toZonedTime';
2
2
  export { toUtc } from './toUtc';
3
- export { toUtcString } from './toUtcString';
3
+ export { toIso, type IsoMode, type ToIsoOptions } from './toIso';
4
+ export { toIso9075, type ToIso9075Options, type Iso9075Representation, type Iso9075Mode, } from './toIso9075';
4
5
  export { toDate } from './toDate';
5
6
  export { format, type FormatOptions } from './format';
6
7
  export { formatPlainDate, type FormatPlainDateOptions } from './formatPlainDate';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAA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CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import {
2
- toUtcString
3
- } from "./chunk-DMKGJY4N.js";
2
+ toIso9075
3
+ } from "./chunk-DFLGGK4F.js";
4
+ import {
5
+ toUtc
6
+ } from "./chunk-BW5SFCKS.js";
4
7
  import {
5
8
  toZonedTime
6
9
  } from "./chunk-2MP3ESL7.js";
@@ -26,8 +29,8 @@ import {
26
29
  toDate
27
30
  } from "./chunk-TGKWBQ7L.js";
28
31
  import {
29
- toUtc
30
- } from "./chunk-BW5SFCKS.js";
32
+ toIso
33
+ } from "./chunk-BSV32PSO.js";
31
34
  import {
32
35
  startOfMonth
33
36
  } from "./chunk-TU2UNOOW.js";
@@ -257,8 +260,9 @@ export {
257
260
  subWeeks,
258
261
  subYears,
259
262
  toDate,
263
+ toIso,
264
+ toIso9075,
260
265
  toUtc,
261
- toUtcString,
262
266
  toZonedTime,
263
267
  today
264
268
  };
@@ -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,7 @@
1
+ import {
2
+ toIso
3
+ } from "./chunk-BSV32PSO.js";
4
+ export {
5
+ toIso
6
+ };
7
+ //# sourceMappingURL=toIso.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=toIso.test.d.ts.map
@@ -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,7 @@
1
+ import {
2
+ toIso9075
3
+ } from "./chunk-DFLGGK4F.js";
4
+ export {
5
+ toIso9075
6
+ };
7
+ //# sourceMappingURL=toIso9075.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=toIso9075.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toIso9075.test.d.ts","sourceRoot":"","sources":["../src/toIso9075.test.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobrand/tiempo",
3
- "version": "2.3.6",
3
+ "version": "2.4.0",
4
4
  "description": "Lightweight utility functions for converting between UTC and timezone-aware datetimes using the Temporal API",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -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":[]}
@@ -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"}
@@ -1,7 +0,0 @@
1
- import {
2
- toUtcString
3
- } from "./chunk-DMKGJY4N.js";
4
- export {
5
- toUtcString
6
- };
7
- //# sourceMappingURL=toUtcString.js.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=toUtcString.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toUtcString.test.d.ts","sourceRoot":"","sources":["../src/toUtcString.test.ts"],"names":[],"mappings":""}
File without changes