@thi.ng/date 2.7.5 → 2.7.7

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-03-07T20:40:47Z
3
+ - **Last updated**: 2024-03-13T14:04:31Z
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.
package/duration.d.ts CHANGED
@@ -11,10 +11,12 @@ export declare const decomposeDuration: (dur: number) => number[];
11
11
  * {@link decomposeDuration}.
12
12
  *
13
13
  * @example
14
- * ```ts
14
+ * ```ts tangle:../export/compose-duration.ts
15
15
  * import { composeDuration } from "@thi.ng/date";
16
16
  *
17
- * composeDuration({ h: 12, m: 34, s: 56 })
17
+ * console.log(
18
+ * composeDuration({ h: 12, m: 34, s: 56 })
19
+ * );
18
20
  * // 45296000
19
21
  * ```
20
22
  *
@@ -25,9 +27,12 @@ export declare const composeDuration: (parts: Partial<Record<Precision, number>>
25
27
  * Calculates the given duration in units of given `prec`ision.
26
28
  *
27
29
  * @example
28
- * ```ts
29
- * import { durationAs } from "@thi.ng/date";
30
- * durationAs("d", difference("2023-02-01T12:00:00Z", "2023-01-01"))
30
+ * ```ts tangle:../export/duration-as.ts
31
+ * import { durationAs, difference } from "@thi.ng/date";
32
+ *
33
+ * console.log(
34
+ * durationAs("d", difference("2023-02-01T12:00:00Z", "2023-01-01"))
35
+ * );
31
36
  * // 31.5
32
37
  * ```
33
38
  *
package/format.d.ts CHANGED
@@ -14,15 +14,19 @@ export declare const FORMATTERS: Record<string, FormatFn>;
14
14
  * formatter and use as a string literal, prefix the term with `\\`.
15
15
  *
16
16
  * @example
17
- * ```ts
17
+ * ```ts tangle:../export/def-format.ts
18
18
  * import { defFormat } from "@thi.ng/date";
19
19
  *
20
20
  * const fmt = defFormat(["yyyy", "-", "MM", "-", "dd"]);
21
21
  *
22
- * fmt(new Date(2015, 3, 23))
22
+ * console.log(
23
+ * fmt(new Date(2015, 3, 23))
24
+ * );
23
25
  * // "2015-04-23"
24
26
  *
25
- * defFormat(["\\yyyy"])(new Date(2015, 3, 23))
27
+ * console.log(
28
+ * defFormat(["\\yyyy"])(new Date(2015, 3, 23))
29
+ * );
26
30
  * // "yyyy"
27
31
  * ```
28
32
  *
@@ -129,19 +133,27 @@ export declare const FMT_ss: (x?: MaybeDate, utc?: boolean) => string;
129
133
  *
130
134
  *
131
135
  * @example
132
- * ```ts
136
+ * ```ts tangle:../export/format-relative.ts
133
137
  * import { formatRelative } from "@thi.ng/date";
134
138
  *
135
- * formatRelative("2020-06-01", "2021-07-01")
139
+ * console.log(
140
+ * formatRelative("2020-06-01", "2021-07-01")
141
+ * );
136
142
  * // "1 year ago"
137
143
  *
138
- * formatRelative("2020-08-01", "2021-07-01")
144
+ * console.log(
145
+ * formatRelative("2020-08-01", "2021-07-01")
146
+ * );
139
147
  * // "11 months ago"
140
148
  *
141
- * formatRelative("2021-07-01 13:45", "2021-07-01 12:05")
149
+ * console.log(
150
+ * formatRelative("2021-07-01 13:45", "2021-07-01 12:05")
151
+ * );
142
152
  * // "in 2 hours"
143
153
  *
144
- * formatRelative("2021-07-01 12:23:24", "2021-07-01 12:05")
154
+ * console.log(
155
+ * formatRelative("2021-07-01 12:23:24", "2021-07-01 12:05")
156
+ * );
145
157
  * // "in 18 minutes"
146
158
  * ```
147
159
  *
@@ -163,18 +175,26 @@ export declare const formatRelative: (date: MaybeDate, base?: MaybeDate, prec?:
163
175
  * given dates to extract parts for formatting.
164
176
  *
165
177
  * @example
166
- * ```ts
167
- * import { formatRelativeParts } from "@thi.ng/date";
178
+ * ```ts tangle:../export/format-relative-parts.ts
179
+ * import { formatRelativeParts, setLocale, EN_LONG } from "@thi.ng/date";
180
+ *
181
+ * setLocale(EN_LONG);
168
182
  *
169
183
  * // with default precision (seconds)
170
- * formatRelativeParts("2022-09-01 12:23:24", "2021-07-01 12:05")
184
+ * console.log(
185
+ * formatRelativeParts("2022-09-01 12:23:24", "2021-07-01 12:05")
186
+ * );
171
187
  * // "in 1 year, 2 months, 21 hours, 18 minutes, 24 seconds"
172
188
  *
173
189
  * // with day precision
174
- * formatRelativeParts("2012-12-25 17:59", "2021-07-01 12:05", "d")
190
+ * console.log(
191
+ * formatRelativeParts("2012-12-25 17:59", "2021-07-01 12:05", "d")
192
+ * );
175
193
  * // "8 years, 6 months, 5 days ago"
176
194
  *
177
- * formatRelativeParts("2021-07-01 17:59", "2021-07-01 12:05", "d")
195
+ * console.log(
196
+ * formatRelativeParts("2021-07-01 17:59", "2021-07-01 12:05", "d")
197
+ * );
178
198
  * // "in less than a day"
179
199
  * ```
180
200
  *
@@ -189,16 +209,22 @@ export declare const formatRelativeParts: (date: MaybeDate, base?: MaybeDate, pr
189
209
  * {@link LOCALE}.
190
210
  *
191
211
  * @example
192
- * ```ts
212
+ * ```ts tangle:../export/format-duration.ts
193
213
  * import { formatDuration } from "@thi.ng/date";
194
214
  *
195
- * formatDuration(45296000)
215
+ * console.log(
216
+ * formatDuration(45296000)
217
+ * );
196
218
  * // "12 h, 34 min, 56 s"
197
219
  *
198
- * formatDuration(45296000, "h")
220
+ * console.log(
221
+ * formatDuration(45296000, "h")
222
+ * );
199
223
  * // "13 h"
200
224
  *
201
- * formatDuration(45296000,"d")
225
+ * console.log(
226
+ * formatDuration(45296000,"d")
227
+ * );
202
228
  * // "< 1 d"
203
229
  * ```
204
230
  *
package/i18n.d.ts CHANGED
@@ -37,25 +37,37 @@ export declare const monthNames: () => string[];
37
37
  * {@link formatRelativeParts}.
38
38
  *
39
39
  * @example
40
- * ```ts
41
- * import { withLocale } from "@thi.ng/date";
40
+ * ```ts tangle:../export/units.ts
41
+ * import { units, withLocale, FR_LONG, DE_LONG } from "@thi.ng/date";
42
42
  *
43
- * withLocale(FR_LONG, () => units(1, "y"));
43
+ * console.log(
44
+ * withLocale(FR_LONG, () => units(1, "y"))
45
+ * );
44
46
  * // "1 année"
45
47
  *
46
- * withLocale(FR_LONG, () => units(1, "y", true));
48
+ * console.log(
49
+ * withLocale(FR_LONG, () => units(1, "y", true))
50
+ * );
47
51
  * // "1 an"
48
52
  *
49
- * withLocale(FR_LONG, () => units(2, "y"));
53
+ * console.log(
54
+ * withLocale(FR_LONG, () => units(2, "y"))
55
+ * );
50
56
  * // "2 ans"
51
57
  *
52
- * withLocale(FR_LONG, () => units(2, "y", true));
58
+ * console.log(
59
+ * withLocale(FR_LONG, () => units(2, "y", true))
60
+ * );
53
61
  * // "2 ans"
54
62
  *
55
- * withLocale(DE_LONG, () => units(2, "y"));
63
+ * console.log(
64
+ * withLocale(DE_LONG, () => units(2, "y"))
65
+ * );
56
66
  * // "2 Jahre"
57
67
  *
58
- * withLocale(DE_LONG, () => units(2, "y", true));
68
+ * console.log(
69
+ * withLocale(DE_LONG, () => units(2, "y", true))
70
+ * );
59
71
  * // "2 Jahren"
60
72
  * ```
61
73
  *
@@ -70,10 +82,12 @@ export declare const units: (x: number, unit: Precision | LocaleUnit, isDativ?:
70
82
  * than {x} {unit(s)}`.
71
83
  *
72
84
  * @example
73
- * ```ts
74
- * import { withLocale } from "@thi.ng/date";
85
+ * ```ts tangle:../export/units-less-than.ts
86
+ * import { unitsLessThan, withLocale, DE_LONG } from "@thi.ng/date";
75
87
  *
76
- * withLocale(DE_LONG, () => unitsLessThan(1, "y"));
88
+ * console.log(
89
+ * withLocale(DE_LONG, () => unitsLessThan(1, "y"))
90
+ * );
77
91
  * // "weniger als 1 Jahr"
78
92
  * ```
79
93
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/date",
3
- "version": "2.7.5",
3
+ "version": "2.7.7",
4
4
  "description": "Datetime types, relative dates, math, iterators, composable formatters, locales",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -36,16 +36,16 @@
36
36
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@thi.ng/api": "^8.9.28",
40
- "@thi.ng/checks": "^3.5.2",
41
- "@thi.ng/strings": "^3.7.21"
39
+ "@thi.ng/api": "^8.9.30",
40
+ "@thi.ng/checks": "^3.5.3",
41
+ "@thi.ng/strings": "^3.7.23"
42
42
  },
43
43
  "devDependencies": {
44
- "@microsoft/api-extractor": "^7.40.1",
45
- "esbuild": "^0.20.0",
44
+ "@microsoft/api-extractor": "^7.42.3",
45
+ "esbuild": "^0.20.1",
46
46
  "rimraf": "^5.0.5",
47
- "typedoc": "^0.25.7",
48
- "typescript": "^5.3.3"
47
+ "typedoc": "^0.25.12",
48
+ "typescript": "^5.4.2"
49
49
  },
50
50
  "keywords": [
51
51
  "datastructure",
@@ -133,5 +133,5 @@
133
133
  "thi.ng": {
134
134
  "year": 2020
135
135
  },
136
- "gitHead": "a421058a65ba76608d94129ac29451bfedaf201c\n"
136
+ "gitHead": "7f3fcbd6c0462b0ce45afa141fe163d1f297fd51\n"
137
137
  }
package/timecode.d.ts CHANGED
@@ -9,18 +9,24 @@
9
9
  * via 2nd arg (default: all `:`).
10
10
  *
11
11
  * @example
12
- * ```ts
13
- * import { defTimecode } from "@thi.ng/date";
12
+ * ```ts tangle:../export/timecode.ts
13
+ * import { defTimecode, DAY, HOUR, MINUTE, SECOND } from "@thi.ng/date";
14
14
  *
15
- * a = defTimecode(30);
16
- * a(HOUR + 2*MINUTE + 3*SECOND + 4*1000/30)
15
+ * const fmt = defTimecode(30);
16
+ *
17
+ * console.log(
18
+ * fmt(HOUR + 2*MINUTE + 3*SECOND + 4*1000/30)
19
+ * );
17
20
  * // "01:02:03:04"
18
21
  *
19
- * a(DAY);
22
+ * console.log(fmt(DAY));
20
23
  * // "01:00:00:00:00"
21
24
  *
22
- * b = defTimecode(30, ["d ", "h ", "' ", '" ']);
23
- * b(Day + HOUR + 2*MINUTE + 3*SECOND + 999)
25
+ * const fmt2 = defTimecode(30, ["d ", "h ", "' ", '" ']);
26
+ *
27
+ * console.log(
28
+ * fmt2(DAY + HOUR + 2 * MINUTE + 3 * SECOND + 999)
29
+ * );
24
30
  * // "01d 01h 02' 03" 29"
25
31
  * ```
26
32
  *