@gobrand/tiempo 0.1.2 → 2.0.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
@@ -29,71 +29,104 @@ The Temporal API is already designed for timezone conversions, but it requires u
29
29
  ## Quick Start
30
30
 
31
31
  ```typescript
32
- import { utcToZonedTime, zonedTimeToUtc } from '@gobrand/tiempo';
32
+ import { toZonedTime, toUtcString } from '@gobrand/tiempo';
33
33
 
34
34
  // Backend sends: "2025-01-20T20:00:00.000Z"
35
- const zoned = utcToZonedTime("2025-01-20T20:00:00.000Z", "America/New_York");
35
+ const zoned = toZonedTime("2025-01-20T20:00:00.000Z", "America/New_York");
36
36
  console.log(zoned.hour); // 15 (3 PM in New York)
37
37
 
38
38
  // Send back to backend:
39
- const utc = zonedTimeToUtc(zoned);
39
+ const utc = toUtcString(zoned);
40
40
  console.log(utc); // "2025-01-20T20:00:00Z"
41
41
  ```
42
42
 
43
43
  ## API
44
44
 
45
- ### `utcToZonedTime(isoString, timezone)`
45
+ ### `toZonedTime(input, timezone)`
46
46
 
47
- Convert a UTC ISO string to a ZonedDateTime in the given timezone.
47
+ Convert a UTC ISO string, Instant, or ZonedDateTime to a ZonedDateTime in the specified timezone.
48
48
 
49
49
  **Parameters:**
50
- - `isoString` (string): A UTC ISO 8601 string (e.g., `"2025-01-20T20:00:00.000Z"`)
50
+ - `input` (string | Temporal.Instant | Temporal.ZonedDateTime): A UTC ISO 8601 string, Temporal.Instant, or Temporal.ZonedDateTime
51
51
  - `timezone` (string): An IANA timezone identifier (e.g., `"America/New_York"`, `"Europe/London"`)
52
52
 
53
53
  **Returns:** `Temporal.ZonedDateTime` - The same instant in the specified timezone
54
54
 
55
55
  **Example:**
56
56
  ```typescript
57
- import { utcToZonedTime } from '@gobrand/tiempo';
58
-
59
- // Backend sends: "2025-01-20T20:00:00.000Z"
60
- const zoned = utcToZonedTime("2025-01-20T20:00:00.000Z", "America/New_York");
57
+ import { toZonedTime } from '@gobrand/tiempo';
61
58
 
59
+ // From ISO string
60
+ const zoned = toZonedTime("2025-01-20T20:00:00.000Z", "America/New_York");
62
61
  console.log(zoned.hour); // 15 (3 PM in New York)
63
62
  console.log(zoned.toString()); // "2025-01-20T15:00:00-05:00[America/New_York]"
63
+
64
+ // From Instant
65
+ const instant = Temporal.Instant.from("2025-01-20T20:00:00Z");
66
+ const zoned2 = toZonedTime(instant, "Asia/Tokyo");
67
+
68
+ // From ZonedDateTime (convert to different timezone)
69
+ const nyTime = Temporal.ZonedDateTime.from("2025-01-20T15:00:00-05:00[America/New_York]");
70
+ const tokyoTime = toZonedTime(nyTime, "Asia/Tokyo");
64
71
  ```
65
72
 
66
- ### `zonedTimeToUtc(zonedDateTime)`
73
+ ### `toUtc(input)`
67
74
 
68
- Convert a ZonedDateTime to a UTC ISO string.
75
+ Convert a UTC ISO string or ZonedDateTime to a Temporal.Instant (UTC).
69
76
 
70
77
  **Parameters:**
71
- - `zonedDateTime` (`Temporal.ZonedDateTime`): A Temporal.ZonedDateTime instance
78
+ - `input` (string | Temporal.ZonedDateTime): A UTC ISO 8601 string or Temporal.ZonedDateTime
72
79
 
73
- **Returns:** `string` - A UTC ISO 8601 string representation of the instant
80
+ **Returns:** `Temporal.Instant` - A Temporal.Instant representing the same moment in UTC
74
81
 
75
82
  **Example:**
76
83
  ```typescript
77
- import { zonedTimeToUtc, utcToZonedTime } from '@gobrand/tiempo';
84
+ import { toUtc } from '@gobrand/tiempo';
78
85
 
79
- const zoned = utcToZonedTime("2025-01-20T20:00:00.000Z", "America/New_York");
86
+ // From ISO string
87
+ const instant = toUtc("2025-01-20T20:00:00.000Z");
80
88
 
81
- // Send back to backend:
82
- const utc = zonedTimeToUtc(zoned);
83
- console.log(utc); // "2025-01-20T20:00:00Z"
89
+ // From ZonedDateTime
90
+ const zoned = Temporal.ZonedDateTime.from("2025-01-20T15:00:00-05:00[America/New_York]");
91
+ const instant2 = toUtc(zoned);
92
+ // Both represent the same UTC moment: 2025-01-20T20:00:00Z
93
+ ```
94
+
95
+ ### `toUtcString(input)`
96
+
97
+ Convert a Temporal.Instant or ZonedDateTime to a UTC ISO 8601 string.
98
+
99
+ **Parameters:**
100
+ - `input` (Temporal.Instant | Temporal.ZonedDateTime): A Temporal.Instant or Temporal.ZonedDateTime
101
+
102
+ **Returns:** `string` - A UTC ISO 8601 string representation
103
+
104
+ **Example:**
105
+ ```typescript
106
+ import { toUtcString } from '@gobrand/tiempo';
107
+
108
+ // From ZonedDateTime
109
+ const zoned = Temporal.ZonedDateTime.from("2025-01-20T15:00:00-05:00[America/New_York]");
110
+ const iso = toUtcString(zoned);
111
+ console.log(iso); // "2025-01-20T20:00:00Z"
112
+
113
+ // From Instant
114
+ const instant = Temporal.Instant.from("2025-01-20T20:00:00Z");
115
+ const iso2 = toUtcString(instant);
116
+ console.log(iso2); // "2025-01-20T20:00:00Z"
84
117
  ```
85
118
 
86
119
  ## Complete Workflow Example
87
120
 
88
121
  ```typescript
89
- import { utcToZonedTime, zonedTimeToUtc } from '@gobrand/tiempo';
122
+ import { toZonedTime, toUtcString } from '@gobrand/tiempo';
90
123
 
91
124
  // 1. Receive UTC datetime from backend
92
125
  const scheduledAtUTC = "2025-01-20T20:00:00.000Z";
93
126
 
94
127
  // 2. Convert to user's timezone for display/editing
95
128
  const userTimezone = "America/New_York";
96
- const zonedDateTime = utcToZonedTime(scheduledAtUTC, userTimezone);
129
+ const zonedDateTime = toZonedTime(scheduledAtUTC, userTimezone);
97
130
 
98
131
  console.log(`Scheduled for: ${zonedDateTime.hour}:00`); // "Scheduled for: 15:00"
99
132
 
@@ -101,7 +134,7 @@ console.log(`Scheduled for: ${zonedDateTime.hour}:00`); // "Scheduled for: 15:00
101
134
  const updatedZoned = zonedDateTime.with({ hour: 16 });
102
135
 
103
136
  // 4. Convert back to UTC for sending to backend
104
- const updatedUTC = zonedTimeToUtc(updatedZoned);
137
+ const updatedUTC = toUtcString(updatedZoned);
105
138
  console.log(updatedUTC); // "2025-01-20T21:00:00Z"
106
139
  ```
107
140
 
@@ -0,0 +1,13 @@
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
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,13 @@
1
+ // src/toUtc.ts
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ function toUtc(input) {
4
+ if (typeof input === "string") {
5
+ return Temporal.Instant.from(input);
6
+ }
7
+ return input.toInstant();
8
+ }
9
+
10
+ export {
11
+ toUtc
12
+ };
13
+ //# sourceMappingURL=chunk-GPAFAHKJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/toUtc.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\n/**\n * Convert a UTC ISO string or ZonedDateTime to a Temporal.Instant (UTC).\n *\n * @param input - A UTC ISO 8601 string or Temporal.ZonedDateTime\n * @returns A Temporal.Instant representing the same moment in UTC\n *\n * @example\n * ```typescript\n * // From ISO string\n * const instant = toUtc(\"2025-01-20T20:00:00.000Z\");\n *\n * // From ZonedDateTime\n * const zoned = Temporal.ZonedDateTime.from(\"2025-01-20T15:00:00-05:00[America/New_York]\");\n * const instant2 = toUtc(zoned);\n * // Both represent the same UTC moment: 2025-01-20T20:00:00Z\n * ```\n */\nexport function toUtc(\n input: string | Temporal.ZonedDateTime\n): Temporal.Instant {\n if (typeof input === 'string') {\n return Temporal.Instant.from(input);\n }\n\n return input.toInstant();\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAmBlB,SAAS,MACd,OACkB;AAClB,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,SAAS,QAAQ,KAAK,KAAK;AAAA,EACpC;AAEA,SAAO,MAAM,UAAU;AACzB;","names":[]}
@@ -0,0 +1,16 @@
1
+ // src/toZonedTime.ts
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ function toZonedTime(input, timezone) {
4
+ if (typeof input === "string") {
5
+ return Temporal.Instant.from(input).toZonedDateTimeISO(timezone);
6
+ }
7
+ if (input instanceof Temporal.Instant) {
8
+ return input.toZonedDateTimeISO(timezone);
9
+ }
10
+ return input.toInstant().toZonedDateTimeISO(timezone);
11
+ }
12
+
13
+ export {
14
+ toZonedTime
15
+ };
16
+ //# sourceMappingURL=chunk-KD5GEHUA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/toZonedTime.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\n/**\n * Convert a UTC ISO string, Instant, or ZonedDateTime to a ZonedDateTime in the specified timezone.\n *\n * @param input - A UTC ISO 8601 string, 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 Instant\n * const instant = Temporal.Instant.from(\"2025-01-20T20:00:00Z\");\n * const zoned2 = 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 | 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 Temporal.Instant) {\n return input.toZonedDateTimeISO(timezone);\n }\n\n return input.toInstant().toZonedDateTimeISO(timezone);\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAwBlB,SAAS,YACd,OACA,UACwB;AACxB,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,SAAS,QAAQ,KAAK,KAAK,EAAE,mBAAmB,QAAQ;AAAA,EACjE;AAEA,MAAI,iBAAiB,SAAS,SAAS;AACrC,WAAO,MAAM,mBAAmB,QAAQ;AAAA,EAC1C;AAEA,SAAO,MAAM,UAAU,EAAE,mBAAmB,QAAQ;AACtD;","names":[]}
package/dist/index.d.ts CHANGED
@@ -1,32 +1,4 @@
1
- import { Temporal } from '@js-temporal/polyfill';
2
- /**
3
- * Convert a UTC ISO string to a ZonedDateTime in the given timezone.
4
- *
5
- * @param isoString - A UTC ISO 8601 string (e.g., "2025-01-20T20:00:00.000Z")
6
- * @param timezone - An IANA timezone identifier (e.g., "America/New_York", "Europe/London")
7
- * @returns A Temporal.ZonedDateTime representing the same instant in the specified timezone
8
- *
9
- * @example
10
- * ```typescript
11
- * // Backend sends: "2025-01-20T20:00:00.000Z"
12
- * const zoned = utcToZonedTime("2025-01-20T20:00:00.000Z", "America/New_York");
13
- * // zoned.hour === 15 (3 PM in New York)
14
- * // zoned.toString() === "2025-01-20T15:00:00-05:00[America/New_York]"
15
- * ```
16
- */
17
- export declare function utcToZonedTime(isoString: string, timezone: string): Temporal.ZonedDateTime;
18
- /**
19
- * Convert a ZonedDateTime to a UTC ISO string.
20
- *
21
- * @param zonedDateTime - A Temporal.ZonedDateTime instance
22
- * @returns A UTC ISO 8601 string representation of the instant
23
- *
24
- * @example
25
- * ```typescript
26
- * const zoned = Temporal.ZonedDateTime.from("2025-01-20T15:00:00-05:00[America/New_York]");
27
- * const utc = zonedTimeToUtc(zoned);
28
- * // utc === "2025-01-20T20:00:00Z"
29
- * ```
30
- */
31
- export declare function zonedTimeToUtc(zonedDateTime: Temporal.ZonedDateTime): string;
1
+ export { toZonedTime } from './toZonedTime';
2
+ export { toUtc } from './toUtc';
3
+ export { toUtcString } from './toUtcString';
32
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,QAAQ,CAAC,aAAa,CAExB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,aAAa,EAAE,QAAQ,CAAC,aAAa,GAAG,MAAM,CAE5E"}
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"}
package/dist/index.js CHANGED
@@ -1,13 +1,15 @@
1
- // src/index.ts
2
- import { Temporal } from "@js-temporal/polyfill";
3
- function utcToZonedTime(isoString, timezone) {
4
- return Temporal.Instant.from(isoString).toZonedDateTimeISO(timezone);
5
- }
6
- function zonedTimeToUtc(zonedDateTime) {
7
- return zonedDateTime.toInstant().toString();
8
- }
1
+ import {
2
+ toUtc
3
+ } from "./chunk-GPAFAHKJ.js";
4
+ import {
5
+ toUtcString
6
+ } from "./chunk-DMKGJY4N.js";
7
+ import {
8
+ toZonedTime
9
+ } from "./chunk-KD5GEHUA.js";
9
10
  export {
10
- utcToZonedTime,
11
- zonedTimeToUtc
11
+ toUtc,
12
+ toUtcString,
13
+ toZonedTime
12
14
  };
13
15
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\n/**\n * Convert a UTC ISO string to a ZonedDateTime in the given timezone.\n *\n * @param isoString - A UTC ISO 8601 string (e.g., \"2025-01-20T20:00:00.000Z\")\n * @param timezone - An IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\")\n * @returns A Temporal.ZonedDateTime representing the same instant in the specified timezone\n *\n * @example\n * ```typescript\n * // Backend sends: \"2025-01-20T20:00:00.000Z\"\n * const zoned = utcToZonedTime(\"2025-01-20T20:00:00.000Z\", \"America/New_York\");\n * // zoned.hour === 15 (3 PM in New York)\n * // zoned.toString() === \"2025-01-20T15:00:00-05:00[America/New_York]\"\n * ```\n */\nexport function utcToZonedTime(\n isoString: string,\n timezone: string\n): Temporal.ZonedDateTime {\n return Temporal.Instant.from(isoString).toZonedDateTimeISO(timezone);\n}\n\n/**\n * Convert a ZonedDateTime to a UTC ISO string.\n *\n * @param zonedDateTime - A Temporal.ZonedDateTime instance\n * @returns A UTC ISO 8601 string representation of the instant\n *\n * @example\n * ```typescript\n * const zoned = Temporal.ZonedDateTime.from(\"2025-01-20T15:00:00-05:00[America/New_York]\");\n * const utc = zonedTimeToUtc(zoned);\n * // utc === \"2025-01-20T20:00:00Z\"\n * ```\n */\nexport function zonedTimeToUtc(zonedDateTime: Temporal.ZonedDateTime): string {\n return zonedDateTime.toInstant().toString();\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAiBlB,SAAS,eACd,WACA,UACwB;AACxB,SAAO,SAAS,QAAQ,KAAK,SAAS,EAAE,mBAAmB,QAAQ;AACrE;AAeO,SAAS,eAAe,eAA+C;AAC5E,SAAO,cAAc,UAAU,EAAE,SAAS;AAC5C;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,20 @@
1
+ import { Temporal } from '@js-temporal/polyfill';
2
+ /**
3
+ * Convert a UTC ISO string or ZonedDateTime to a Temporal.Instant (UTC).
4
+ *
5
+ * @param input - A UTC ISO 8601 string or Temporal.ZonedDateTime
6
+ * @returns A Temporal.Instant representing the same moment in UTC
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // From ISO string
11
+ * const instant = toUtc("2025-01-20T20:00:00.000Z");
12
+ *
13
+ * // From ZonedDateTime
14
+ * const zoned = Temporal.ZonedDateTime.from("2025-01-20T15:00:00-05:00[America/New_York]");
15
+ * const instant2 = toUtc(zoned);
16
+ * // Both represent the same UTC moment: 2025-01-20T20:00:00Z
17
+ * ```
18
+ */
19
+ export declare function toUtc(input: string | Temporal.ZonedDateTime): Temporal.Instant;
20
+ //# sourceMappingURL=toUtc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toUtc.d.ts","sourceRoot":"","sources":["../src/toUtc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,KAAK,CACnB,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,aAAa,GACrC,QAAQ,CAAC,OAAO,CAMlB"}
package/dist/toUtc.js ADDED
@@ -0,0 +1,7 @@
1
+ import {
2
+ toUtc
3
+ } from "./chunk-GPAFAHKJ.js";
4
+ export {
5
+ toUtc
6
+ };
7
+ //# sourceMappingURL=toUtc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,22 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,7 @@
1
+ import {
2
+ toUtcString
3
+ } from "./chunk-DMKGJY4N.js";
4
+ export {
5
+ toUtcString
6
+ };
7
+ //# sourceMappingURL=toUtcString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,25 @@
1
+ import { Temporal } from '@js-temporal/polyfill';
2
+ /**
3
+ * Convert a UTC ISO string, Instant, or ZonedDateTime to a ZonedDateTime in the specified timezone.
4
+ *
5
+ * @param input - A UTC ISO 8601 string, Temporal.Instant, or Temporal.ZonedDateTime
6
+ * @param timezone - IANA timezone identifier (e.g., "America/New_York", "Europe/London")
7
+ * @returns A Temporal.ZonedDateTime in the specified timezone
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * // From ISO string
12
+ * const zoned = toZonedTime("2025-01-20T20:00:00.000Z", "America/New_York");
13
+ * // zoned.hour === 15 (3 PM in New York)
14
+ *
15
+ * // From Instant
16
+ * const instant = Temporal.Instant.from("2025-01-20T20:00:00Z");
17
+ * const zoned2 = toZonedTime(instant, "Asia/Tokyo");
18
+ *
19
+ * // From ZonedDateTime (convert to different timezone)
20
+ * const nyTime = Temporal.ZonedDateTime.from("2025-01-20T15:00:00-05:00[America/New_York]");
21
+ * const tokyoTime = toZonedTime(nyTime, "Asia/Tokyo");
22
+ * ```
23
+ */
24
+ export declare function toZonedTime(input: string | Temporal.Instant | Temporal.ZonedDateTime, timezone: string): Temporal.ZonedDateTime;
25
+ //# sourceMappingURL=toZonedTime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toZonedTime.d.ts","sourceRoot":"","sources":["../src/toZonedTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,EACzD,QAAQ,EAAE,MAAM,GACf,QAAQ,CAAC,aAAa,CAUxB"}
@@ -0,0 +1,7 @@
1
+ import {
2
+ toZonedTime
3
+ } from "./chunk-KD5GEHUA.js";
4
+ export {
5
+ toZonedTime
6
+ };
7
+ //# sourceMappingURL=toZonedTime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobrand/tiempo",
3
- "version": "0.1.2",
3
+ "version": "2.0.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": {
@@ -33,7 +33,8 @@
33
33
  "build": "tsup && tsc --emitDeclarationOnly",
34
34
  "clean": "git clean -xdf .cache .turbo dist node_modules tsconfig.tsbuildinfo",
35
35
  "test": "vitest",
36
- "typecheck": "tsc --noEmit"
36
+ "typecheck": "tsc --noEmit",
37
+ "release": "bash scripts/release.sh"
37
38
  },
38
39
  "dependencies": {
39
40
  "@js-temporal/polyfill": "^0.5.1"