@thi.ng/date 2.6.0 β 2.7.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/CHANGELOG.md +7 -1
- package/README.md +1 -1
- package/duration.d.ts +3 -0
- package/format.d.ts +37 -1
- package/format.js +14 -0
- package/i18n.d.ts +4 -0
- package/package.json +4 -4
- package/timecode.d.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-02-
|
|
3
|
+
- **Last updated**: 2024-02-25T14:07:53Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [2.7.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/date@2.7.0) (2024-02-22)
|
|
13
|
+
|
|
14
|
+
#### π Features
|
|
15
|
+
|
|
16
|
+
- add single component formatter presets ([661a4b7](https://github.com/thi-ng/umbrella/commit/661a4b7))
|
|
17
|
+
|
|
12
18
|
## [2.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/date@2.6.0) (2024-02-22)
|
|
13
19
|
|
|
14
20
|
#### π Features
|
package/README.md
CHANGED
package/duration.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export declare const decomposeDuration: (dur: number) => number[];
|
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* ```ts
|
|
15
|
+
* import { composeDuration } from "@thi.ng/date";
|
|
16
|
+
*
|
|
15
17
|
* composeDuration({ h: 12, m: 34, s: 56 })
|
|
16
18
|
* // 45296000
|
|
17
19
|
* ```
|
|
@@ -24,6 +26,7 @@ export declare const composeDuration: (parts: Partial<Record<Precision, number>>
|
|
|
24
26
|
*
|
|
25
27
|
* @example
|
|
26
28
|
* ```ts
|
|
29
|
+
* import { durationAs } from "@thi.ng/date";
|
|
27
30
|
* durationAs("d", difference("2023-02-01T12:00:00Z", "2023-01-01"))
|
|
28
31
|
* // 31.5
|
|
29
32
|
* ```
|
package/format.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export declare const FORMATTERS: Record<string, FormatFn>;
|
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```ts
|
|
18
|
+
* import { defFormat } from "@thi.ng/date";
|
|
19
|
+
*
|
|
18
20
|
* const fmt = defFormat(["yyyy", "-", "MM", "-", "dd"]);
|
|
19
21
|
*
|
|
20
22
|
* fmt(new Date(2015, 3, 23))
|
|
@@ -65,7 +67,7 @@ export declare const FMT_hm: (x?: MaybeDate, utc?: boolean) => string;
|
|
|
65
67
|
*/
|
|
66
68
|
export declare const FMT_HHmmss: (x?: MaybeDate, utc?: boolean) => string;
|
|
67
69
|
/**
|
|
68
|
-
* Format preset, e.g. `
|
|
70
|
+
* Format preset, e.g. `170801`
|
|
69
71
|
*/
|
|
70
72
|
export declare const FMT_HHmmss_ALT: (x?: MaybeDate, utc?: boolean) => string;
|
|
71
73
|
/**
|
|
@@ -86,6 +88,34 @@ export declare const FMT_ISO_SHORT: (x?: MaybeDate, utc?: boolean) => string;
|
|
|
86
88
|
* `2020-09-19T17:08:01.123Z`
|
|
87
89
|
*/
|
|
88
90
|
export declare const FMT_ISO: (x?: MaybeDate, utc?: boolean) => string;
|
|
91
|
+
/**
|
|
92
|
+
* Format preset, 4-digit year only
|
|
93
|
+
*/
|
|
94
|
+
export declare const FMT_yyyy: (x?: MaybeDate, utc?: boolean) => string;
|
|
95
|
+
/**
|
|
96
|
+
* Format preset, 2-digit month only
|
|
97
|
+
*/
|
|
98
|
+
export declare const FMT_MM: (x?: MaybeDate, utc?: boolean) => string;
|
|
99
|
+
/**
|
|
100
|
+
* Format preset, 2-digit week in year only
|
|
101
|
+
*/
|
|
102
|
+
export declare const FMT_ww: (x?: MaybeDate, utc?: boolean) => string;
|
|
103
|
+
/**
|
|
104
|
+
* Format preset, 2-digit day in month only
|
|
105
|
+
*/
|
|
106
|
+
export declare const FMT_dd: (x?: MaybeDate, utc?: boolean) => string;
|
|
107
|
+
/**
|
|
108
|
+
* Format preset, 2-digit hour only
|
|
109
|
+
*/
|
|
110
|
+
export declare const FMT_HH: (x?: MaybeDate, utc?: boolean) => string;
|
|
111
|
+
/**
|
|
112
|
+
* Format preset, 2-digit minute only
|
|
113
|
+
*/
|
|
114
|
+
export declare const FMT_mm: (x?: MaybeDate, utc?: boolean) => string;
|
|
115
|
+
/**
|
|
116
|
+
* Format preset, 2-digit second only
|
|
117
|
+
*/
|
|
118
|
+
export declare const FMT_ss: (x?: MaybeDate, utc?: boolean) => string;
|
|
89
119
|
/**
|
|
90
120
|
* Takes a `date` and optional reference `base` date and (also optional
|
|
91
121
|
* `prec`ision, i.e. number of fractional digits, default: 0). Computes the
|
|
@@ -100,6 +130,8 @@ export declare const FMT_ISO: (x?: MaybeDate, utc?: boolean) => string;
|
|
|
100
130
|
*
|
|
101
131
|
* @example
|
|
102
132
|
* ```ts
|
|
133
|
+
* import { formatRelative } from "@thi.ng/date";
|
|
134
|
+
*
|
|
103
135
|
* formatRelative("2020-06-01", "2021-07-01")
|
|
104
136
|
* // "1 year ago"
|
|
105
137
|
*
|
|
@@ -132,6 +164,8 @@ export declare const formatRelative: (date: MaybeDate, base?: MaybeDate, prec?:
|
|
|
132
164
|
*
|
|
133
165
|
* @example
|
|
134
166
|
* ```ts
|
|
167
|
+
* import { formatRelativeParts } from "@thi.ng/date";
|
|
168
|
+
*
|
|
135
169
|
* // with default precision (seconds)
|
|
136
170
|
* formatRelativeParts("2022-09-01 12:23:24", "2021-07-01 12:05")
|
|
137
171
|
* // "in 1 year, 2 months, 21 hours, 18 minutes, 24 seconds"
|
|
@@ -156,6 +190,8 @@ export declare const formatRelativeParts: (date: MaybeDate, base?: MaybeDate, pr
|
|
|
156
190
|
*
|
|
157
191
|
* @example
|
|
158
192
|
* ```ts
|
|
193
|
+
* import { formatDuration } from "@thi.ng/date";
|
|
194
|
+
*
|
|
159
195
|
* formatDuration(45296000)
|
|
160
196
|
* // "12 h, 34 min, 56 s"
|
|
161
197
|
*
|
package/format.js
CHANGED
|
@@ -179,6 +179,13 @@ const FMT_ISO_SHORT = defFormat(
|
|
|
179
179
|
const FMT_ISO = defFormat(
|
|
180
180
|
["yyyy", "-", "MM", "-", "dd", "T", "HH", ":", "mm", ":", "ss", ".", "SS", "ZZ"]
|
|
181
181
|
);
|
|
182
|
+
const FMT_yyyy = defFormat(["yyyy"]);
|
|
183
|
+
const FMT_MM = defFormat(["MM"]);
|
|
184
|
+
const FMT_ww = defFormat(["ww"]);
|
|
185
|
+
const FMT_dd = defFormat(["dd"]);
|
|
186
|
+
const FMT_HH = defFormat(["HH"]);
|
|
187
|
+
const FMT_mm = defFormat(["mm"]);
|
|
188
|
+
const FMT_ss = defFormat(["ss"]);
|
|
182
189
|
const formatRelative = (date, base = /* @__PURE__ */ new Date(), prec = 0, eps = 100) => {
|
|
183
190
|
const delta = difference(date, base);
|
|
184
191
|
if (Math.abs(delta) < eps)
|
|
@@ -238,17 +245,24 @@ const formatDurationParts = (parts, prec = "s") => {
|
|
|
238
245
|
}).filter((x) => !!x).join(", ");
|
|
239
246
|
};
|
|
240
247
|
export {
|
|
248
|
+
FMT_HH,
|
|
241
249
|
FMT_HHmm,
|
|
242
250
|
FMT_HHmmss,
|
|
243
251
|
FMT_HHmmss_ALT,
|
|
244
252
|
FMT_ISO,
|
|
245
253
|
FMT_ISO_SHORT,
|
|
254
|
+
FMT_MM,
|
|
246
255
|
FMT_MMMdyyyy,
|
|
247
256
|
FMT_Mdyyyy,
|
|
248
257
|
FMT_dMMMyyyy,
|
|
249
258
|
FMT_dMyyyy,
|
|
259
|
+
FMT_dd,
|
|
250
260
|
FMT_hm,
|
|
251
261
|
FMT_hms,
|
|
262
|
+
FMT_mm,
|
|
263
|
+
FMT_ss,
|
|
264
|
+
FMT_ww,
|
|
265
|
+
FMT_yyyy,
|
|
252
266
|
FMT_yyyyMMdd,
|
|
253
267
|
FMT_yyyyMMdd_ALT,
|
|
254
268
|
FMT_yyyyMMdd_HHmmss,
|
package/i18n.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ export declare const monthNames: () => string[];
|
|
|
38
38
|
*
|
|
39
39
|
* @example
|
|
40
40
|
* ```ts
|
|
41
|
+
* import { withLocale } from "@thi.ng/date";
|
|
42
|
+
*
|
|
41
43
|
* withLocale(FR_LONG, () => units(1, "y"));
|
|
42
44
|
* // "1 annΓ©e"
|
|
43
45
|
*
|
|
@@ -69,6 +71,8 @@ export declare const units: (x: number, unit: Precision | LocaleUnit, isDativ?:
|
|
|
69
71
|
*
|
|
70
72
|
* @example
|
|
71
73
|
* ```ts
|
|
74
|
+
* import { withLocale } from "@thi.ng/date";
|
|
75
|
+
*
|
|
72
76
|
* withLocale(DE_LONG, () => unitsLessThan(1, "y"));
|
|
73
77
|
* // "weniger als 1 Jahr"
|
|
74
78
|
* ```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/date",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"description": "Datetime types, relative dates, math, iterators, composable formatters, locales",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"test": "bun test"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@thi.ng/api": "^8.9.
|
|
38
|
+
"@thi.ng/api": "^8.9.26",
|
|
39
39
|
"@thi.ng/checks": "^3.5.0",
|
|
40
|
-
"@thi.ng/strings": "^3.7.
|
|
40
|
+
"@thi.ng/strings": "^3.7.17"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@microsoft/api-extractor": "^7.40.1",
|
|
@@ -132,5 +132,5 @@
|
|
|
132
132
|
"thi.ng": {
|
|
133
133
|
"year": 2020
|
|
134
134
|
},
|
|
135
|
-
"gitHead": "
|
|
135
|
+
"gitHead": "6e20f80dd9df1c8055ffa3c1e4d6f7598add0c0b\n"
|
|
136
136
|
}
|