@thi.ng/date 2.5.18 → 2.7.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/CHANGELOG.md +13 -1
- package/README.md +2 -2
- package/format.d.ts +36 -0
- package/format.js +18 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-02-
|
|
3
|
+
- **Last updated**: 2024-02-22T23:15:26Z
|
|
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,18 @@ 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
|
+
|
|
18
|
+
## [2.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/date@2.6.0) (2024-02-22)
|
|
19
|
+
|
|
20
|
+
#### 🚀 Features
|
|
21
|
+
|
|
22
|
+
- add FMT_yyyyMMdd_ALT and FMT_HHmmss_ALT formatters ([658bcf9](https://github.com/thi-ng/umbrella/commit/658bcf9))
|
|
23
|
+
|
|
12
24
|
## [2.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/date@2.5.0) (2023-11-04)
|
|
13
25
|
|
|
14
26
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
[](https://mastodon.thi.ng/@toxi)
|
|
19
19
|
|
|
20
20
|
> [!NOTE]
|
|
21
|
-
> This is one of
|
|
21
|
+
> This is one of 190 standalone projects, maintained as part
|
|
22
22
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
23
23
|
> and anti-framework.
|
|
24
24
|
>
|
|
@@ -73,7 +73,7 @@ For Node.js REPL:
|
|
|
73
73
|
const date = await import("@thi.ng/date");
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 5.
|
|
76
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 5.38 KB
|
|
77
77
|
|
|
78
78
|
## Dependencies
|
|
79
79
|
|
package/format.d.ts
CHANGED
|
@@ -31,6 +31,10 @@ export declare const defFormat: (fmt: (string | FormatFn)[]) => (x?: MaybeDate,
|
|
|
31
31
|
* Format preset, e.g. `2020-09-19`
|
|
32
32
|
*/
|
|
33
33
|
export declare const FMT_yyyyMMdd: (x?: MaybeDate, utc?: boolean) => string;
|
|
34
|
+
/**
|
|
35
|
+
* Format preset, e.g. `20200919`
|
|
36
|
+
*/
|
|
37
|
+
export declare const FMT_yyyyMMdd_ALT: (x?: MaybeDate, utc?: boolean) => string;
|
|
34
38
|
/**
|
|
35
39
|
* Format preset, e.g. `9/19/2020`
|
|
36
40
|
*/
|
|
@@ -60,6 +64,10 @@ export declare const FMT_hm: (x?: MaybeDate, utc?: boolean) => string;
|
|
|
60
64
|
* Format preset, e.g. `17:08:01`
|
|
61
65
|
*/
|
|
62
66
|
export declare const FMT_HHmmss: (x?: MaybeDate, utc?: boolean) => string;
|
|
67
|
+
/**
|
|
68
|
+
* Format preset, e.g. `170801`
|
|
69
|
+
*/
|
|
70
|
+
export declare const FMT_HHmmss_ALT: (x?: MaybeDate, utc?: boolean) => string;
|
|
63
71
|
/**
|
|
64
72
|
* Format preset, e.g. `5:08:01 PM`
|
|
65
73
|
*/
|
|
@@ -78,6 +86,34 @@ export declare const FMT_ISO_SHORT: (x?: MaybeDate, utc?: boolean) => string;
|
|
|
78
86
|
* `2020-09-19T17:08:01.123Z`
|
|
79
87
|
*/
|
|
80
88
|
export declare const FMT_ISO: (x?: MaybeDate, utc?: boolean) => string;
|
|
89
|
+
/**
|
|
90
|
+
* Format preset, 4-digit year only
|
|
91
|
+
*/
|
|
92
|
+
export declare const FMT_yyyy: (x?: MaybeDate, utc?: boolean) => string;
|
|
93
|
+
/**
|
|
94
|
+
* Format preset, 2-digit month only
|
|
95
|
+
*/
|
|
96
|
+
export declare const FMT_MM: (x?: MaybeDate, utc?: boolean) => string;
|
|
97
|
+
/**
|
|
98
|
+
* Format preset, 2-digit week in year only
|
|
99
|
+
*/
|
|
100
|
+
export declare const FMT_ww: (x?: MaybeDate, utc?: boolean) => string;
|
|
101
|
+
/**
|
|
102
|
+
* Format preset, 2-digit day in month only
|
|
103
|
+
*/
|
|
104
|
+
export declare const FMT_dd: (x?: MaybeDate, utc?: boolean) => string;
|
|
105
|
+
/**
|
|
106
|
+
* Format preset, 2-digit hour only
|
|
107
|
+
*/
|
|
108
|
+
export declare const FMT_HH: (x?: MaybeDate, utc?: boolean) => string;
|
|
109
|
+
/**
|
|
110
|
+
* Format preset, 2-digit minute only
|
|
111
|
+
*/
|
|
112
|
+
export declare const FMT_mm: (x?: MaybeDate, utc?: boolean) => string;
|
|
113
|
+
/**
|
|
114
|
+
* Format preset, 2-digit second only
|
|
115
|
+
*/
|
|
116
|
+
export declare const FMT_ss: (x?: MaybeDate, utc?: boolean) => string;
|
|
81
117
|
/**
|
|
82
118
|
* Takes a `date` and optional reference `base` date and (also optional
|
|
83
119
|
* `prec`ision, i.e. number of fractional digits, default: 0). Computes the
|
package/format.js
CHANGED
|
@@ -160,6 +160,7 @@ const defFormat = (fmt) => (x = Date.now(), utc = false) => {
|
|
|
160
160
|
}).join("");
|
|
161
161
|
};
|
|
162
162
|
const FMT_yyyyMMdd = defFormat(["yyyy", "-", "MM", "-", "dd"]);
|
|
163
|
+
const FMT_yyyyMMdd_ALT = defFormat(["yyyy", "MM", "dd"]);
|
|
163
164
|
const FMT_Mdyyyy = defFormat(["M", "/", "d", "/", "yyyy"]);
|
|
164
165
|
const FMT_MMMdyyyy = defFormat(["MMM", " ", "d", " ", "yyyy"]);
|
|
165
166
|
const FMT_dMyyyy = defFormat(["d", "~", "M", "~", "yyyy"]);
|
|
@@ -167,6 +168,7 @@ const FMT_dMMMyyyy = defFormat(["d", "~~", "MMM", " ", "yyyy"]);
|
|
|
167
168
|
const FMT_HHmm = defFormat(["HH", ":", "mm"]);
|
|
168
169
|
const FMT_hm = defFormat(["h", ":", "mm", " ", "A"]);
|
|
169
170
|
const FMT_HHmmss = defFormat(["HH", ":", "mm", ":", "ss"]);
|
|
171
|
+
const FMT_HHmmss_ALT = defFormat(["HH", "mm", "ss"]);
|
|
170
172
|
const FMT_hms = defFormat(["h", ":", "mm", ":", "ss", " ", "A"]);
|
|
171
173
|
const FMT_yyyyMMdd_HHmmss = defFormat(
|
|
172
174
|
["yyyy", "MM", "dd", "-", "HH", "mm", "ss"]
|
|
@@ -177,6 +179,13 @@ const FMT_ISO_SHORT = defFormat(
|
|
|
177
179
|
const FMT_ISO = defFormat(
|
|
178
180
|
["yyyy", "-", "MM", "-", "dd", "T", "HH", ":", "mm", ":", "ss", ".", "SS", "ZZ"]
|
|
179
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"]);
|
|
180
189
|
const formatRelative = (date, base = /* @__PURE__ */ new Date(), prec = 0, eps = 100) => {
|
|
181
190
|
const delta = difference(date, base);
|
|
182
191
|
if (Math.abs(delta) < eps)
|
|
@@ -236,17 +245,26 @@ const formatDurationParts = (parts, prec = "s") => {
|
|
|
236
245
|
}).filter((x) => !!x).join(", ");
|
|
237
246
|
};
|
|
238
247
|
export {
|
|
248
|
+
FMT_HH,
|
|
239
249
|
FMT_HHmm,
|
|
240
250
|
FMT_HHmmss,
|
|
251
|
+
FMT_HHmmss_ALT,
|
|
241
252
|
FMT_ISO,
|
|
242
253
|
FMT_ISO_SHORT,
|
|
254
|
+
FMT_MM,
|
|
243
255
|
FMT_MMMdyyyy,
|
|
244
256
|
FMT_Mdyyyy,
|
|
245
257
|
FMT_dMMMyyyy,
|
|
246
258
|
FMT_dMyyyy,
|
|
259
|
+
FMT_dd,
|
|
247
260
|
FMT_hm,
|
|
248
261
|
FMT_hms,
|
|
262
|
+
FMT_mm,
|
|
263
|
+
FMT_ss,
|
|
264
|
+
FMT_ww,
|
|
265
|
+
FMT_yyyy,
|
|
249
266
|
FMT_yyyyMMdd,
|
|
267
|
+
FMT_yyyyMMdd_ALT,
|
|
250
268
|
FMT_yyyyMMdd_HHmmss,
|
|
251
269
|
FORMATTERS,
|
|
252
270
|
defFormat,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/date",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
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.
|
|
39
|
-
"@thi.ng/checks": "^3.
|
|
40
|
-
"@thi.ng/strings": "^3.7.
|
|
38
|
+
"@thi.ng/api": "^8.9.25",
|
|
39
|
+
"@thi.ng/checks": "^3.5.0",
|
|
40
|
+
"@thi.ng/strings": "^3.7.16"
|
|
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": "16f2b92b5410bd35dcde6c2971c8e62783ebc472\n"
|
|
136
136
|
}
|