@gobrand/tiempo 2.1.4 → 2.2.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 +43 -0
- package/dist/chunk-3YGPHHB6.js +13 -0
- package/dist/chunk-3YGPHHB6.js.map +1 -0
- package/dist/chunk-67QHALIG.js +13 -0
- package/dist/chunk-67QHALIG.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -4
- package/dist/now.d.ts +21 -0
- package/dist/now.d.ts.map +1 -0
- package/dist/now.js +7 -0
- package/dist/now.js.map +1 -0
- package/dist/now.test.d.ts +2 -0
- package/dist/now.test.d.ts.map +1 -0
- package/dist/today.d.ts +21 -0
- package/dist/today.d.ts.map +1 -0
- package/dist/today.js +7 -0
- package/dist/today.js.map +1 -0
- package/dist/today.test.d.ts +2 -0
- package/dist/today.test.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -173,6 +173,49 @@ format(instant, "yyyy-MM-dd HH:mm", { timeZone: "Asia/Tokyo" }); // "2025-01-21
|
|
|
173
173
|
|
|
174
174
|
### Start/End Utilities
|
|
175
175
|
|
|
176
|
+
#### `today(timezone?)`
|
|
177
|
+
|
|
178
|
+
Get today's date in the system's local timezone or a specified timezone.
|
|
179
|
+
|
|
180
|
+
**Parameters:**
|
|
181
|
+
- `timezone` (string, optional): An IANA timezone identifier (e.g., `"America/New_York"`, `"Europe/Madrid"`) or `"UTC"`. If not provided, uses the system's local timezone.
|
|
182
|
+
|
|
183
|
+
**Returns:** `Temporal.PlainDate` - A Temporal.PlainDate representing today's date
|
|
184
|
+
|
|
185
|
+
**Example:**
|
|
186
|
+
```typescript
|
|
187
|
+
import { today } from '@gobrand/tiempo';
|
|
188
|
+
|
|
189
|
+
const date = today(); // 2025-01-20
|
|
190
|
+
date.year; // 2025
|
|
191
|
+
date.month; // 1
|
|
192
|
+
date.day; // 20
|
|
193
|
+
|
|
194
|
+
// Get today in a specific timezone
|
|
195
|
+
const dateInTokyo = today("Asia/Tokyo"); // 2025-01-21 (next day due to timezone)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
#### `now(timezone?)`
|
|
199
|
+
|
|
200
|
+
Get the current date and time in the system's local timezone or a specified timezone.
|
|
201
|
+
|
|
202
|
+
**Parameters:**
|
|
203
|
+
- `timezone` (string, optional): An IANA timezone identifier (e.g., `"America/New_York"`, `"Europe/Madrid"`) or `"UTC"`. If not provided, uses the system's local timezone.
|
|
204
|
+
|
|
205
|
+
**Returns:** `Temporal.ZonedDateTime` - A Temporal.ZonedDateTime representing the current date and time
|
|
206
|
+
|
|
207
|
+
**Example:**
|
|
208
|
+
```typescript
|
|
209
|
+
import { now } from '@gobrand/tiempo';
|
|
210
|
+
|
|
211
|
+
const current = now(); // 2025-01-20T15:30:45.123-05:00[America/New_York]
|
|
212
|
+
current.hour; // 15
|
|
213
|
+
current.minute; // 30
|
|
214
|
+
|
|
215
|
+
// Get current time in a specific timezone
|
|
216
|
+
const currentInTokyo = now("Asia/Tokyo"); // 2025-01-21T05:30:45.123+09:00[Asia/Tokyo]
|
|
217
|
+
```
|
|
218
|
+
|
|
176
219
|
#### `startOfDay(input)` / `endOfDay(input)`
|
|
177
220
|
|
|
178
221
|
Get the start or end of the day for a given datetime.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/now.ts
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
function now(timezone) {
|
|
4
|
+
if (timezone) {
|
|
5
|
+
return Temporal.Now.zonedDateTimeISO(timezone);
|
|
6
|
+
}
|
|
7
|
+
return Temporal.Now.zonedDateTimeISO();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
now
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=chunk-3YGPHHB6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/now.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\n/**\n * Get the current date and time in the system's local timezone or a specified timezone.\n *\n * @param timezone - Optional IANA timezone identifier (e.g., \"America/Asuncion\", \"Europe/Madrid\") or \"UTC\"\n * @returns A Temporal.ZonedDateTime representing the current date and time\n *\n * @example\n * ```typescript\n * // Get now in local timezone\n * const current = now();\n *\n * // Get now in Madrid\n * const nowInMadrid = now(\"Europe/Madrid\");\n *\n * // Get now in UTC\n * const nowUtc = now(\"UTC\");\n * ```\n */\nexport function now(timezone?: 'UTC' | string): Temporal.ZonedDateTime {\n if (timezone) {\n return Temporal.Now.zonedDateTimeISO(timezone);\n }\n return Temporal.Now.zonedDateTimeISO();\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAoBlB,SAAS,IAAI,UAAmD;AACrE,MAAI,UAAU;AACZ,WAAO,SAAS,IAAI,iBAAiB,QAAQ;AAAA,EAC/C;AACA,SAAO,SAAS,IAAI,iBAAiB;AACvC;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/today.ts
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
function today(timezone) {
|
|
4
|
+
if (timezone) {
|
|
5
|
+
return Temporal.Now.zonedDateTimeISO(timezone).toPlainDate();
|
|
6
|
+
}
|
|
7
|
+
return Temporal.Now.plainDateISO();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
today
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=chunk-67QHALIG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/today.ts"],"sourcesContent":["import { Temporal } from '@js-temporal/polyfill';\n\n/**\n * Get today's date in the system's local timezone or a specified timezone.\n *\n * @param timezone - Optional IANA timezone identifier (e.g., \"America/Asuncion\", \"Europe/Madrid\") or \"UTC\"\n * @returns A Temporal.PlainDate representing today's date\n *\n * @example\n * ```typescript\n * // Get today in local timezone\n * const date = today();\n *\n * // Get today in Madrid\n * const todayInMadrid = today(\"Europe/Madrid\");\n *\n * // Get today in UTC\n * const todayUtc = today(\"UTC\");\n * ```\n */\nexport function today(timezone?: \"UTC\" | string): Temporal.PlainDate {\n if (timezone) {\n return Temporal.Now.zonedDateTimeISO(timezone).toPlainDate();\n }\n return Temporal.Now.plainDateISO();\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAoBlB,SAAS,MAAM,UAA+C;AACnE,MAAI,UAAU;AACZ,WAAO,SAAS,IAAI,iBAAiB,QAAQ,EAAE,YAAY;AAAA,EAC7D;AACA,SAAO,SAAS,IAAI,aAAa;AACnC;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export { toZonedTime } from './toZonedTime';
|
|
|
2
2
|
export { toUtc } from './toUtc';
|
|
3
3
|
export { toUtcString } from './toUtcString';
|
|
4
4
|
export { format, type FormatOptions } from './format';
|
|
5
|
+
export { today } from './today';
|
|
6
|
+
export { now } from './now';
|
|
5
7
|
export { startOfDay } from './startOfDay';
|
|
6
8
|
export { endOfDay } from './endOfDay';
|
|
7
9
|
export { startOfWeek } from './startOfWeek';
|
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;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACtD,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,EAAE,MAAM,aA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ACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
toUtcString
|
|
3
|
+
} from "./chunk-DMKGJY4N.js";
|
|
1
4
|
import {
|
|
2
5
|
toZonedTime
|
|
3
6
|
} from "./chunk-KD5GEHUA.js";
|
|
7
|
+
import {
|
|
8
|
+
today
|
|
9
|
+
} from "./chunk-67QHALIG.js";
|
|
4
10
|
import {
|
|
5
11
|
isSameDay
|
|
6
12
|
} from "./chunk-RW3C2677.js";
|
|
13
|
+
import {
|
|
14
|
+
now
|
|
15
|
+
} from "./chunk-3YGPHHB6.js";
|
|
7
16
|
import {
|
|
8
17
|
startOfDay
|
|
9
18
|
} from "./chunk-TW5EV3DH.js";
|
|
@@ -19,9 +28,6 @@ import {
|
|
|
19
28
|
import {
|
|
20
29
|
toUtc
|
|
21
30
|
} from "./chunk-GPAFAHKJ.js";
|
|
22
|
-
import {
|
|
23
|
-
toUtcString
|
|
24
|
-
} from "./chunk-DMKGJY4N.js";
|
|
25
31
|
import {
|
|
26
32
|
endOfDay
|
|
27
33
|
} from "./chunk-CUMB4776.js";
|
|
@@ -54,12 +60,14 @@ export {
|
|
|
54
60
|
isAfter,
|
|
55
61
|
isBefore,
|
|
56
62
|
isSameDay,
|
|
63
|
+
now,
|
|
57
64
|
startOfDay,
|
|
58
65
|
startOfMonth,
|
|
59
66
|
startOfWeek,
|
|
60
67
|
startOfYear,
|
|
61
68
|
toUtc,
|
|
62
69
|
toUtcString,
|
|
63
|
-
toZonedTime
|
|
70
|
+
toZonedTime,
|
|
71
|
+
today
|
|
64
72
|
};
|
|
65
73
|
//# sourceMappingURL=index.js.map
|
package/dist/now.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
/**
|
|
3
|
+
* Get the current date and time in the system's local timezone or a specified timezone.
|
|
4
|
+
*
|
|
5
|
+
* @param timezone - Optional IANA timezone identifier (e.g., "America/Asuncion", "Europe/Madrid") or "UTC"
|
|
6
|
+
* @returns A Temporal.ZonedDateTime representing the current date and time
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // Get now in local timezone
|
|
11
|
+
* const current = now();
|
|
12
|
+
*
|
|
13
|
+
* // Get now in Madrid
|
|
14
|
+
* const nowInMadrid = now("Europe/Madrid");
|
|
15
|
+
*
|
|
16
|
+
* // Get now in UTC
|
|
17
|
+
* const nowUtc = now("UTC");
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function now(timezone?: 'UTC' | string): Temporal.ZonedDateTime;
|
|
21
|
+
//# sourceMappingURL=now.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"now.d.ts","sourceRoot":"","sources":["../src/now.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,GAAG,CAAC,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC,aAAa,CAKrE"}
|
package/dist/now.js
ADDED
package/dist/now.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"now.test.d.ts","sourceRoot":"","sources":["../src/now.test.ts"],"names":[],"mappings":""}
|
package/dist/today.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Temporal } from '@js-temporal/polyfill';
|
|
2
|
+
/**
|
|
3
|
+
* Get today's date in the system's local timezone or a specified timezone.
|
|
4
|
+
*
|
|
5
|
+
* @param timezone - Optional IANA timezone identifier (e.g., "America/Asuncion", "Europe/Madrid") or "UTC"
|
|
6
|
+
* @returns A Temporal.PlainDate representing today's date
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // Get today in local timezone
|
|
11
|
+
* const date = today();
|
|
12
|
+
*
|
|
13
|
+
* // Get today in Madrid
|
|
14
|
+
* const todayInMadrid = today("Europe/Madrid");
|
|
15
|
+
*
|
|
16
|
+
* // Get today in UTC
|
|
17
|
+
* const todayUtc = today("UTC");
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function today(timezone?: "UTC" | string): Temporal.PlainDate;
|
|
21
|
+
//# sourceMappingURL=today.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"today.d.ts","sourceRoot":"","sources":["../src/today.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,KAAK,CAAC,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC,SAAS,CAKnE"}
|
package/dist/today.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"today.test.d.ts","sourceRoot":"","sources":["../src/today.test.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED