@gobrand/tiempo 2.1.0 → 2.1.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 +6 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -146,9 +146,11 @@ Format a Temporal.Instant or ZonedDateTime using date-fns-like format tokens.
|
|
|
146
146
|
|
|
147
147
|
**Example:**
|
|
148
148
|
```typescript
|
|
149
|
-
import { format } from '@gobrand/tiempo';
|
|
149
|
+
import { format, toZonedTime, toUtc } from '@gobrand/tiempo';
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
// From ISO string to ZonedDateTime, then format
|
|
152
|
+
const isoString = "2025-01-20T20:30:45.000Z";
|
|
153
|
+
const zoned = toZonedTime(isoString, "America/New_York");
|
|
152
154
|
|
|
153
155
|
format(zoned, "yyyy-MM-dd"); // "2025-01-20"
|
|
154
156
|
format(zoned, "MMMM d, yyyy"); // "January 20, 2025"
|
|
@@ -159,8 +161,8 @@ format(zoned, "EEEE, MMMM do, yyyy 'at' h:mm a"); // "Monday, January 20th, 2025
|
|
|
159
161
|
format(zoned, "MMMM d, yyyy", { locale: "es-ES" }); // "enero 20, 2025"
|
|
160
162
|
format(zoned, "EEEE", { locale: "fr-FR" }); // "lundi"
|
|
161
163
|
|
|
162
|
-
//
|
|
163
|
-
const instant =
|
|
164
|
+
// From ISO string to Instant (UTC), then format with timezone conversion
|
|
165
|
+
const instant = toUtc(isoString);
|
|
164
166
|
format(instant, "yyyy-MM-dd HH:mm", { timeZone: "America/New_York" }); // "2025-01-20 15:30"
|
|
165
167
|
format(instant, "yyyy-MM-dd HH:mm", { timeZone: "Asia/Tokyo" }); // "2025-01-21 05:30"
|
|
166
168
|
```
|
package/package.json
CHANGED