@thi.ng/date 2.1.5 → 2.2.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/format.d.ts +16 -13
- package/format.js +5 -2
- package/package.json +25 -25
- package/relative.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2022-
|
|
3
|
+
- **Last updated**: 2022-05-18T12:59:20Z
|
|
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.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/date@2.2.0) (2022-05-18)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- use current time as default for all formatters ([ee536db](https://github.com/thi-ng/umbrella/commit/ee536db))
|
|
17
|
+
|
|
18
|
+
### [2.1.6](https://github.com/thi-ng/umbrella/tree/@thi.ng/date@2.1.6) (2022-04-07)
|
|
19
|
+
|
|
20
|
+
#### ♻️ Refactoring
|
|
21
|
+
|
|
22
|
+
- replace deprecated .substr() w/ .substring() ([0710509](https://github.com/thi-ng/umbrella/commit/0710509))
|
|
23
|
+
|
|
12
24
|
## [2.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/date@2.1.0) (2021-11-17)
|
|
13
25
|
|
|
14
26
|
#### 🚀 Features
|
package/format.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export declare const FORMATTERS: Record<string, FormatFn>;
|
|
|
7
7
|
* instead of local time (default).
|
|
8
8
|
*
|
|
9
9
|
* @remarks
|
|
10
|
+
* If no date is given to the returned formatter, `Date.now()` will be used by
|
|
11
|
+
* default.
|
|
12
|
+
*
|
|
10
13
|
* See {@link FORMATTERS} for available date component format IDs. To escape a
|
|
11
14
|
* formatter and use as a string literal, prefix the term with `\\`.
|
|
12
15
|
*
|
|
@@ -23,56 +26,56 @@ export declare const FORMATTERS: Record<string, FormatFn>;
|
|
|
23
26
|
*
|
|
24
27
|
* @param fmt -
|
|
25
28
|
*/
|
|
26
|
-
export declare const defFormat: (fmt: (string | FormatFn)[]) => (x
|
|
29
|
+
export declare const defFormat: (fmt: (string | FormatFn)[]) => (x?: MaybeDate, utc?: boolean) => string;
|
|
27
30
|
/**
|
|
28
31
|
* Format preset, e.g. `2020-09-19`
|
|
29
32
|
*/
|
|
30
|
-
export declare const FMT_yyyyMMdd: (x
|
|
33
|
+
export declare const FMT_yyyyMMdd: (x?: MaybeDate, utc?: boolean) => string;
|
|
31
34
|
/**
|
|
32
35
|
* Format preset, e.g. `9/19/2020`
|
|
33
36
|
*/
|
|
34
|
-
export declare const FMT_Mdyyyy: (x
|
|
37
|
+
export declare const FMT_Mdyyyy: (x?: MaybeDate, utc?: boolean) => string;
|
|
35
38
|
/**
|
|
36
39
|
* Format preset, e.g. `Sep 19 2020`. Uses current `LOCALE`, see
|
|
37
40
|
* {@link setLocale}.
|
|
38
41
|
*/
|
|
39
|
-
export declare const FMT_MMMdyyyy: (x
|
|
42
|
+
export declare const FMT_MMMdyyyy: (x?: MaybeDate, utc?: boolean) => string;
|
|
40
43
|
/**
|
|
41
44
|
* Format preset, e.g. `19.9.2020`
|
|
42
45
|
*/
|
|
43
|
-
export declare const FMT_dMyyyy: (x
|
|
46
|
+
export declare const FMT_dMyyyy: (x?: MaybeDate, utc?: boolean) => string;
|
|
44
47
|
/**
|
|
45
48
|
* Format preset, e.g. `19 Sep 2020`
|
|
46
49
|
*/
|
|
47
|
-
export declare const FMT_dMMMyyyy: (x
|
|
50
|
+
export declare const FMT_dMMMyyyy: (x?: MaybeDate, utc?: boolean) => string;
|
|
48
51
|
/**
|
|
49
52
|
* Format preset, e.g. `17:08`
|
|
50
53
|
*/
|
|
51
|
-
export declare const FMT_HHmm: (x
|
|
54
|
+
export declare const FMT_HHmm: (x?: MaybeDate, utc?: boolean) => string;
|
|
52
55
|
/**
|
|
53
56
|
* Format preset, e.g. `5:08 PM`
|
|
54
57
|
*/
|
|
55
|
-
export declare const FMT_hm: (x
|
|
58
|
+
export declare const FMT_hm: (x?: MaybeDate, utc?: boolean) => string;
|
|
56
59
|
/**
|
|
57
60
|
* Format preset, e.g. `17:08:01`
|
|
58
61
|
*/
|
|
59
|
-
export declare const FMT_HHmmss: (x
|
|
62
|
+
export declare const FMT_HHmmss: (x?: MaybeDate, utc?: boolean) => string;
|
|
60
63
|
/**
|
|
61
64
|
* Format preset, e.g. `5:08:01 PM`
|
|
62
65
|
*/
|
|
63
|
-
export declare const FMT_hms: (x
|
|
66
|
+
export declare const FMT_hms: (x?: MaybeDate, utc?: boolean) => string;
|
|
64
67
|
/**
|
|
65
68
|
* Format preset, e.g. `20200919-170801`
|
|
66
69
|
*/
|
|
67
|
-
export declare const FMT_yyyyMMdd_HHmmss: (x
|
|
70
|
+
export declare const FMT_yyyyMMdd_HHmmss: (x?: MaybeDate, utc?: boolean) => string;
|
|
68
71
|
/**
|
|
69
72
|
* ISO8601 format preset (without millisecond term), e.g.
|
|
70
73
|
* `2020-09-19T17:08:01Z`
|
|
71
74
|
*/
|
|
72
|
-
export declare const FMT_ISO_SHORT: (x
|
|
75
|
+
export declare const FMT_ISO_SHORT: (x?: MaybeDate, utc?: boolean) => string;
|
|
73
76
|
/**
|
|
74
77
|
* ISO8601 format preset (with millisecond term), e.g.
|
|
75
78
|
* `2020-09-19T17:08:01.123Z`
|
|
76
79
|
*/
|
|
77
|
-
export declare const FMT_ISO: (x
|
|
80
|
+
export declare const FMT_ISO: (x?: MaybeDate, utc?: boolean) => string;
|
|
78
81
|
//# sourceMappingURL=format.d.ts.map
|
package/format.js
CHANGED
|
@@ -148,6 +148,9 @@ export const FORMATTERS = {
|
|
|
148
148
|
* instead of local time (default).
|
|
149
149
|
*
|
|
150
150
|
* @remarks
|
|
151
|
+
* If no date is given to the returned formatter, `Date.now()` will be used by
|
|
152
|
+
* default.
|
|
153
|
+
*
|
|
151
154
|
* See {@link FORMATTERS} for available date component format IDs. To escape a
|
|
152
155
|
* formatter and use as a string literal, prefix the term with `\\`.
|
|
153
156
|
*
|
|
@@ -164,7 +167,7 @@ export const FORMATTERS = {
|
|
|
164
167
|
*
|
|
165
168
|
* @param fmt -
|
|
166
169
|
*/
|
|
167
|
-
export const defFormat = (fmt) => (x, utc = false) => {
|
|
170
|
+
export const defFormat = (fmt) => (x = Date.now(), utc = false) => {
|
|
168
171
|
let d = ensureDate(x);
|
|
169
172
|
utc && (d = new Date(d.getTime() + d.getTimezoneOffset() * MINUTE));
|
|
170
173
|
return fmt
|
|
@@ -172,7 +175,7 @@ export const defFormat = (fmt) => (x, utc = false) => {
|
|
|
172
175
|
let fn;
|
|
173
176
|
return isString(x)
|
|
174
177
|
? x.startsWith("\\")
|
|
175
|
-
? x.
|
|
178
|
+
? x.substring(1)
|
|
176
179
|
: (fn = FORMATTERS[x])
|
|
177
180
|
? fn(d, utc)
|
|
178
181
|
: x
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/date",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Datetime types, relative dates, math, iterators, composable formatters, locales",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.3.
|
|
38
|
-
"@thi.ng/checks": "^3.1.
|
|
39
|
-
"@thi.ng/strings": "^3.3.
|
|
37
|
+
"@thi.ng/api": "^8.3.6",
|
|
38
|
+
"@thi.ng/checks": "^3.1.6",
|
|
39
|
+
"@thi.ng/strings": "^3.3.4"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@microsoft/api-extractor": "^7.
|
|
43
|
-
"@thi.ng/testament": "^0.2.
|
|
42
|
+
"@microsoft/api-extractor": "^7.23.1",
|
|
43
|
+
"@thi.ng/testament": "^0.2.6",
|
|
44
44
|
"rimraf": "^3.0.2",
|
|
45
45
|
"tools": "^0.0.1",
|
|
46
|
-
"typedoc": "^0.22.
|
|
47
|
-
"typescript": "^4.6.
|
|
46
|
+
"typedoc": "^0.22.15",
|
|
47
|
+
"typescript": "^4.6.4"
|
|
48
48
|
},
|
|
49
49
|
"keywords": [
|
|
50
50
|
"datastructure",
|
|
@@ -78,56 +78,56 @@
|
|
|
78
78
|
],
|
|
79
79
|
"exports": {
|
|
80
80
|
".": {
|
|
81
|
-
"
|
|
81
|
+
"default": "./index.js"
|
|
82
82
|
},
|
|
83
83
|
"./api": {
|
|
84
|
-
"
|
|
84
|
+
"default": "./api.js"
|
|
85
85
|
},
|
|
86
86
|
"./checks": {
|
|
87
|
-
"
|
|
87
|
+
"default": "./checks.js"
|
|
88
88
|
},
|
|
89
89
|
"./datetime": {
|
|
90
|
-
"
|
|
90
|
+
"default": "./datetime.js"
|
|
91
91
|
},
|
|
92
92
|
"./format": {
|
|
93
|
-
"
|
|
93
|
+
"default": "./format.js"
|
|
94
94
|
},
|
|
95
95
|
"./i18n/de": {
|
|
96
|
-
"
|
|
96
|
+
"default": "./i18n/de.js"
|
|
97
97
|
},
|
|
98
98
|
"./i18n/en": {
|
|
99
|
-
"
|
|
99
|
+
"default": "./i18n/en.js"
|
|
100
100
|
},
|
|
101
101
|
"./i18n/es": {
|
|
102
|
-
"
|
|
102
|
+
"default": "./i18n/es.js"
|
|
103
103
|
},
|
|
104
104
|
"./i18n/fr": {
|
|
105
|
-
"
|
|
105
|
+
"default": "./i18n/fr.js"
|
|
106
106
|
},
|
|
107
107
|
"./i18n/it": {
|
|
108
|
-
"
|
|
108
|
+
"default": "./i18n/it.js"
|
|
109
109
|
},
|
|
110
110
|
"./i18n": {
|
|
111
|
-
"
|
|
111
|
+
"default": "./i18n.js"
|
|
112
112
|
},
|
|
113
113
|
"./iterators": {
|
|
114
|
-
"
|
|
114
|
+
"default": "./iterators.js"
|
|
115
115
|
},
|
|
116
116
|
"./relative": {
|
|
117
|
-
"
|
|
117
|
+
"default": "./relative.js"
|
|
118
118
|
},
|
|
119
119
|
"./round": {
|
|
120
|
-
"
|
|
120
|
+
"default": "./round.js"
|
|
121
121
|
},
|
|
122
122
|
"./timecode": {
|
|
123
|
-
"
|
|
123
|
+
"default": "./timecode.js"
|
|
124
124
|
},
|
|
125
125
|
"./units": {
|
|
126
|
-
"
|
|
126
|
+
"default": "./units.js"
|
|
127
127
|
}
|
|
128
128
|
},
|
|
129
129
|
"thi.ng": {
|
|
130
130
|
"year": 2020
|
|
131
131
|
},
|
|
132
|
-
"gitHead": "
|
|
132
|
+
"gitHead": "f696c94665a3adef4fa475d99dd2e18ceb15863f\n"
|
|
133
133
|
}
|
package/relative.js
CHANGED
|
@@ -77,7 +77,7 @@ const parseNum = (x, past) => (x === "next " || x === "a " || x === "an " ? 1 :
|
|
|
77
77
|
const parsePeriod = (x) => {
|
|
78
78
|
x =
|
|
79
79
|
x !== "s" && x !== "ms" && x.endsWith("s")
|
|
80
|
-
? x.
|
|
80
|
+
? x.substring(0, x.length - 1)
|
|
81
81
|
: x;
|
|
82
82
|
return {
|
|
83
83
|
ms: "t",
|