@bevelo/date 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +35 -2
- package/dist/civil-GPupvlwZ.d.cts +116 -0
- package/dist/civil-GPupvlwZ.d.ts +116 -0
- package/dist/civil-QU5EukOm.cjs +461 -0
- package/dist/civil-SGLjw0gL.js +366 -0
- package/dist/index.cjs +506 -0
- package/dist/index.d.cts +302 -0
- package/dist/index.d.ts +302 -0
- package/dist/index.js +449 -0
- package/dist/pattern.cjs +328 -0
- package/dist/pattern.d.cts +75 -0
- package/dist/pattern.d.ts +75 -0
- package/dist/pattern.js +323 -0
- package/dist/timezone-BmJA-u4N.js +417 -0
- package/dist/timezone-DiMSaNmI.cjs +560 -0
- package/dist/timezone.cjs +10 -0
- package/dist/timezone.d.cts +108 -0
- package/dist/timezone.d.ts +108 -0
- package/dist/timezone.js +1 -0
- package/package.json +45 -3
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { t as CivilDate } from "./civil-GPupvlwZ.js";
|
|
2
|
+
/** The wall-clock fields of an instant in a zone, to the second. */
|
|
3
|
+
export type ZonedParts = {
|
|
4
|
+
year: number;
|
|
5
|
+
month: number;
|
|
6
|
+
day: number;
|
|
7
|
+
hour: number;
|
|
8
|
+
minute: number;
|
|
9
|
+
second: number;
|
|
10
|
+
};
|
|
11
|
+
/** A wall-clock time of day a date picker can name: whole hours and minutes. */
|
|
12
|
+
export type ZoneTime = {
|
|
13
|
+
hour: number;
|
|
14
|
+
minute: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The UTC offset of a zone at an instant, in minutes.
|
|
18
|
+
*
|
|
19
|
+
* Computed by asking Intl for the wall clock and subtracting it from the instant:
|
|
20
|
+
* no offset table, no transition list. The offset is positive east of Greenwich,
|
|
21
|
+
* so Asia/Kolkata returns 330 and America/New_York returns -300 in January.
|
|
22
|
+
*
|
|
23
|
+
* Whole minutes are the norm, but the result is not rounded: historical
|
|
24
|
+
* local-mean-time offsets (before standard time was adopted) include seconds, and
|
|
25
|
+
* a function that silently rounded them would be wrong for a century of dates.
|
|
26
|
+
* Fractions of a second in the instant are ignored, because the wall clock is
|
|
27
|
+
* read to the second.
|
|
28
|
+
*
|
|
29
|
+
* @throws RangeError when the instant is not finite or the zone is unknown.
|
|
30
|
+
*/
|
|
31
|
+
export declare function offsetAt(instant: number, zone: string): number;
|
|
32
|
+
/**
|
|
33
|
+
* The wall-clock fields of an instant in a zone.
|
|
34
|
+
*
|
|
35
|
+
* Seconds are reported; milliseconds are not, because a calendar never renders
|
|
36
|
+
* them and CivilTime is the only place this package keeps a millisecond field.
|
|
37
|
+
*
|
|
38
|
+
* @throws RangeError when the instant is not finite or the zone is unknown.
|
|
39
|
+
*/
|
|
40
|
+
export declare function zonedParts(instant: number, zone: string): ZonedParts;
|
|
41
|
+
/**
|
|
42
|
+
* The civil date in a zone at an instant.
|
|
43
|
+
*
|
|
44
|
+
* This is the answer to "which day is it there?" - the question a calendar
|
|
45
|
+
* header, a "today" button or a reminder schedule asks, and the one a UTC-only
|
|
46
|
+
* answer gets wrong for half the world for part of every day.
|
|
47
|
+
*
|
|
48
|
+
* @throws RangeError when the instant is not finite or the zone is unknown.
|
|
49
|
+
*/
|
|
50
|
+
export declare function civilInZone(instant: number, zone: string): CivilDate;
|
|
51
|
+
/**
|
|
52
|
+
* The instant a wall clock in a zone names.
|
|
53
|
+
*
|
|
54
|
+
* With no time, this is the start of that civil day in that zone. Both DST
|
|
55
|
+
* disambiguations are the package policy, documented on `toDate` and
|
|
56
|
+
* implemented once there:
|
|
57
|
+
*
|
|
58
|
+
* - a nonexistent wall clock (the skipped hour when the clocks spring forward)
|
|
59
|
+
* maps to the instant the clock jumped to, so 2024-03-10 02:30 in New York is
|
|
60
|
+
* the instant whose local clock reads 03:30;
|
|
61
|
+
* - an ambiguous wall clock (the repeated hour when they fall back) maps to the
|
|
62
|
+
* earlier instant, so 2024-11-03 01:30 in New York is the still-daylight one.
|
|
63
|
+
*
|
|
64
|
+
* @throws RangeError when the civil date or the wall time is invalid, or the
|
|
65
|
+
* zone is unknown.
|
|
66
|
+
*/
|
|
67
|
+
export declare function instantFor(civil: CivilDate, zone: string, time?: ZoneTime): number;
|
|
68
|
+
/**
|
|
69
|
+
* The first instant of the civil day an instant falls in.
|
|
70
|
+
*
|
|
71
|
+
* Normally local midnight, but a zone can start its day inside a DST gap (Chile
|
|
72
|
+
* and Lebanon have both moved the clocks at 00:00), and then the first instant
|
|
73
|
+
* of the day is the moment the clock jumped to - 01:00 local, not a nonexistent
|
|
74
|
+
* 00:00. That follows from `instantFor`'s gap policy rather than being a
|
|
75
|
+
* special case here.
|
|
76
|
+
*
|
|
77
|
+
* ./arithmetic also exports a startOfDay, for civil dates, so a barrel that re-exports both has to alias one of them.
|
|
78
|
+
*
|
|
79
|
+
* @throws RangeError when the instant is not finite or the zone is unknown.
|
|
80
|
+
*/
|
|
81
|
+
export declare function startOfDay(instant: number, zone: string): number;
|
|
82
|
+
/**
|
|
83
|
+
* Hours from the start of the civil day an instant falls in to the start of the
|
|
84
|
+
* next one: 24 normally, 23 when the clocks spring forward, 25 when they fall
|
|
85
|
+
* back.
|
|
86
|
+
*
|
|
87
|
+
* Derived from startOfDay on both days rather than from a DST flag, so a zone
|
|
88
|
+
* that shifts by half an hour reports 23.5 or 24.5 and one that shifts by two
|
|
89
|
+
* hours reports 22 or 26. Anything that hardcoded 23/24/25 would silently
|
|
90
|
+
* misreport those zones; Lord Howe Island is the known half-hour case.
|
|
91
|
+
*
|
|
92
|
+
* @throws RangeError when the instant is not finite or the zone is unknown.
|
|
93
|
+
*/
|
|
94
|
+
export declare function dayLength(instant: number, zone: string): number;
|
|
95
|
+
export declare function formatInZone(instant: number, zone: string, options?: Intl.DateTimeFormatOptions, locale?: string): string;
|
|
96
|
+
/**
|
|
97
|
+
* The zone identifiers this runtime knows, from Intl.supportedValuesOf("timeZone").
|
|
98
|
+
*
|
|
99
|
+
* Returns an empty list when the runtime has no supportedValuesOf (older engines
|
|
100
|
+
* and minimal Intl builds), because there is no honest partial answer: guessing a
|
|
101
|
+
* list would make a zone picker offer zones the runtime cannot convert. The list
|
|
102
|
+
* is the runtime's, so it omits aliases and "UTC" even though Intl accepts them;
|
|
103
|
+
* callers that need "UTC" in a picker should add it themselves.
|
|
104
|
+
*
|
|
105
|
+
* Not cached: the runtime's list is small and fixed, while a cache would hide a
|
|
106
|
+
* test or a restricted runtime that removes supportedValuesOf.
|
|
107
|
+
*/
|
|
108
|
+
export declare function zoneIds(): readonly string[];
|
package/dist/timezone.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as civilInZone, n as dayLength, r as formatInZone, i as instantFor, a as offsetAt, o as startOfDay, s as zoneIds, c as zonedParts } from "./timezone-BmJA-u4N.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bevelo/date",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Dates: civil date arithmetic, calendars, ranges, formatting.",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./pattern": {
|
|
16
|
+
"types": "./dist/pattern.d.ts",
|
|
17
|
+
"import": "./dist/pattern.js",
|
|
18
|
+
"require": "./dist/pattern.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./timezone": {
|
|
21
|
+
"types": "./dist/timezone.d.ts",
|
|
22
|
+
"import": "./dist/timezone.js",
|
|
23
|
+
"require": "./dist/timezone.cjs"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"homepage": "https://github.com/bevelo/bevelo#readme",
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/bevelo/bevelo/issues"
|
|
34
|
+
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/bevelo/bevelo.git",
|
|
38
|
+
"directory": "packages/date"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "vp pack",
|
|
45
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
46
|
+
"test": "vp test run"
|
|
47
|
+
}
|
|
6
48
|
}
|