@thi.ng/date 2.7.83 → 2.8.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/README.md CHANGED
@@ -69,7 +69,7 @@ For Node.js REPL:
69
69
  const date = await import("@thi.ng/date");
70
70
  ```
71
71
 
72
- Package sizes (brotli'd, pre-treeshake): ESM: 5.42 KB
72
+ Package sizes (brotli'd, pre-treeshake): ESM: 5.43 KB
73
73
 
74
74
  ## Dependencies
75
75
 
@@ -381,6 +381,7 @@ string literal, prefix the term with `\\`.
381
381
  | `/DM` | Locale-specific day-month separator |
382
382
  | `/MY` | Locale-specific month-year separator |
383
383
  | `/HM` | Locale-specific hour-minute separator |
384
+ | `/MS` | Locale-specific minute-second separator |
384
385
 
385
386
  <small>(Format IDs somewhat based on Java's
386
387
  [SimpleDateFormat](https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/text/SimpleDateFormat.html))</small>
package/api.d.ts CHANGED
@@ -92,6 +92,12 @@ export interface Locale {
92
92
  * @defaultValue ":"
93
93
  */
94
94
  sepHM: string;
95
+ /**
96
+ * Separator between minute & second
97
+ *
98
+ * @defaultValue ":"
99
+ */
100
+ sepMS: string;
95
101
  /**
96
102
  * Singular & plural versions of various date/time units.
97
103
  */
@@ -164,6 +170,10 @@ export type Period = Precision | "w" | "q";
164
170
  */
165
171
  export declare const PERIODS: Record<Period, number>;
166
172
  export type FormatFn = Fn2<Date, boolean, string>;
173
+ /**
174
+ * A function returned by {@link defFormat}.
175
+ */
176
+ export type Formatter = (x?: MaybeDate, utc?: boolean) => string;
167
177
  export type MaybeDate = DateTime | Date | number | string;
168
178
  /**
169
179
  * Date rounding function for {@link MaybeDate} inputs.
package/datetime.d.ts CHANGED
@@ -118,5 +118,5 @@ export declare const ensureDateTime: (x: MaybeDate, prec?: Precision) => DateTim
118
118
  *
119
119
  * @param x -
120
120
  */
121
- export declare const maybeIsDate: (x: any) => x is string | number | DateTime | Date;
121
+ export declare const maybeIsDate: (x: any) => x is string | number | Date | DateTime;
122
122
  //# sourceMappingURL=datetime.d.ts.map
package/format.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type FormatFn, type MaybeDate, type Precision } from "./api.js";
1
+ import { type FormatFn, type Formatter, type MaybeDate, type Precision } from "./api.js";
2
2
  export declare const FORMATTERS: Record<string, FormatFn>;
3
3
  /**
4
4
  * Returns a new date formatter for given array of format strings (or
@@ -32,94 +32,94 @@ export declare const FORMATTERS: Record<string, FormatFn>;
32
32
  *
33
33
  * @param fmt -
34
34
  */
35
- export declare const defFormat: (fmt: (string | FormatFn)[]) => (x?: MaybeDate, utc?: boolean) => string;
35
+ export declare const defFormat: (fmt: (string | FormatFn)[]) => Formatter;
36
36
  /**
37
37
  * Format preset, e.g. `2020-09-19`
38
38
  */
39
- export declare const FMT_yyyyMMdd: (x?: MaybeDate, utc?: boolean) => string;
39
+ export declare const FMT_yyyyMMdd: Formatter;
40
40
  /**
41
41
  * Format preset, e.g. `20200919`
42
42
  */
43
- export declare const FMT_yyyyMMdd_ALT: (x?: MaybeDate, utc?: boolean) => string;
43
+ export declare const FMT_yyyyMMdd_ALT: Formatter;
44
44
  /**
45
45
  * Format preset, e.g. `9/19/2020`
46
46
  */
47
- export declare const FMT_Mdyyyy: (x?: MaybeDate, utc?: boolean) => string;
47
+ export declare const FMT_Mdyyyy: Formatter;
48
48
  /**
49
49
  * Format preset, e.g. `Sep 19 2020`. Uses current `LOCALE`, see
50
50
  * {@link setLocale}.
51
51
  */
52
- export declare const FMT_MMMdyyyy: (x?: MaybeDate, utc?: boolean) => string;
52
+ export declare const FMT_MMMdyyyy: Formatter;
53
53
  /**
54
54
  * Format preset, e.g. `19.9.2020`
55
55
  */
56
- export declare const FMT_dMyyyy: (x?: MaybeDate, utc?: boolean) => string;
56
+ export declare const FMT_dMyyyy: Formatter;
57
57
  /**
58
58
  * Format preset, e.g. `19 Sep 2020`
59
59
  */
60
- export declare const FMT_dMMMyyyy: (x?: MaybeDate, utc?: boolean) => string;
60
+ export declare const FMT_dMMMyyyy: Formatter;
61
61
  /**
62
62
  * Format preset, e.g. `17:08`
63
63
  */
64
- export declare const FMT_HHmm: (x?: MaybeDate, utc?: boolean) => string;
64
+ export declare const FMT_HHmm: Formatter;
65
65
  /**
66
66
  * Format preset, e.g. `5:08 PM`
67
67
  */
68
- export declare const FMT_hm: (x?: MaybeDate, utc?: boolean) => string;
68
+ export declare const FMT_hm: Formatter;
69
69
  /**
70
70
  * Format preset, e.g. `17:08:01`
71
71
  */
72
- export declare const FMT_HHmmss: (x?: MaybeDate, utc?: boolean) => string;
72
+ export declare const FMT_HHmmss: Formatter;
73
73
  /**
74
74
  * Format preset, e.g. `170801`
75
75
  */
76
- export declare const FMT_HHmmss_ALT: (x?: MaybeDate, utc?: boolean) => string;
76
+ export declare const FMT_HHmmss_ALT: Formatter;
77
77
  /**
78
78
  * Format preset, e.g. `5:08:01 PM`
79
79
  */
80
- export declare const FMT_hms: (x?: MaybeDate, utc?: boolean) => string;
80
+ export declare const FMT_hms: Formatter;
81
81
  /**
82
82
  * Format preset, e.g. `20200919-170801`
83
83
  */
84
- export declare const FMT_yyyyMMdd_HHmmss: (x?: MaybeDate, utc?: boolean) => string;
84
+ export declare const FMT_yyyyMMdd_HHmmss: Formatter;
85
85
  /**
86
86
  * ISO8601 format preset (without millisecond term), e.g.
87
87
  * `2020-09-19T17:08:01Z`
88
88
  */
89
- export declare const FMT_ISO_SHORT: (x?: MaybeDate, utc?: boolean) => string;
89
+ export declare const FMT_ISO_SHORT: Formatter;
90
90
  /**
91
91
  * ISO8601 format preset (with millisecond term), e.g.
92
92
  * `2020-09-19T17:08:01.123Z`
93
93
  */
94
- export declare const FMT_ISO: (x?: MaybeDate, utc?: boolean) => string;
94
+ export declare const FMT_ISO: Formatter;
95
95
  /**
96
96
  * Format preset, 4-digit year only
97
97
  */
98
- export declare const FMT_yyyy: (x?: MaybeDate, utc?: boolean) => string;
98
+ export declare const FMT_yyyy: Formatter;
99
99
  /**
100
100
  * Format preset, 2-digit month only
101
101
  */
102
- export declare const FMT_MM: (x?: MaybeDate, utc?: boolean) => string;
102
+ export declare const FMT_MM: Formatter;
103
103
  /**
104
104
  * Format preset, 2-digit week in year only
105
105
  */
106
- export declare const FMT_ww: (x?: MaybeDate, utc?: boolean) => string;
106
+ export declare const FMT_ww: Formatter;
107
107
  /**
108
108
  * Format preset, 2-digit day in month only
109
109
  */
110
- export declare const FMT_dd: (x?: MaybeDate, utc?: boolean) => string;
110
+ export declare const FMT_dd: Formatter;
111
111
  /**
112
112
  * Format preset, 2-digit hour only
113
113
  */
114
- export declare const FMT_HH: (x?: MaybeDate, utc?: boolean) => string;
114
+ export declare const FMT_HH: Formatter;
115
115
  /**
116
116
  * Format preset, 2-digit minute only
117
117
  */
118
- export declare const FMT_mm: (x?: MaybeDate, utc?: boolean) => string;
118
+ export declare const FMT_mm: Formatter;
119
119
  /**
120
120
  * Format preset, 2-digit second only
121
121
  */
122
- export declare const FMT_ss: (x?: MaybeDate, utc?: boolean) => string;
122
+ export declare const FMT_ss: Formatter;
123
123
  /**
124
124
  * Takes a `date` and optional reference `base` date and (also optional
125
125
  * `prec`ision, i.e. number of fractional digits, default: 0). Computes the
package/format.js CHANGED
@@ -146,6 +146,10 @@ const FORMATTERS = {
146
146
  * Current {@link LOCALE}'s hour-minute separator.
147
147
  */
148
148
  "/HM": () => LOCALE.sepHM,
149
+ /**
150
+ * Current {@link LOCALE}'s minute-second separator.
151
+ */
152
+ "/MS": () => LOCALE.sepMS,
149
153
  /**
150
154
  * Current {@link LOCALE}'s month-year separator.
151
155
  */
@@ -162,13 +166,13 @@ const FMT_yyyyMMdd = defFormat(["yyyy", "-", "MM", "-", "dd"]);
162
166
  const FMT_yyyyMMdd_ALT = defFormat(["yyyy", "MM", "dd"]);
163
167
  const FMT_Mdyyyy = defFormat(["M", "/", "d", "/", "yyyy"]);
164
168
  const FMT_MMMdyyyy = defFormat(["MMM", " ", "d", " ", "yyyy"]);
165
- const FMT_dMyyyy = defFormat(["d", "~", "M", "~", "yyyy"]);
166
- const FMT_dMMMyyyy = defFormat(["d", "~~", "MMM", " ", "yyyy"]);
167
- const FMT_HHmm = defFormat(["HH", ":", "mm"]);
168
- const FMT_hm = defFormat(["h", ":", "mm", " ", "A"]);
169
- const FMT_HHmmss = defFormat(["HH", ":", "mm", ":", "ss"]);
169
+ const FMT_dMyyyy = defFormat(["d", "/DM", "M", "/MY", "yyyy"]);
170
+ const FMT_dMMMyyyy = defFormat(["d", "/DM", "MMM", " ", "yyyy"]);
171
+ const FMT_HHmm = defFormat(["HH", "/HM", "mm"]);
172
+ const FMT_hm = defFormat(["h", "/HM", "mm", " ", "A"]);
173
+ const FMT_HHmmss = defFormat(["HH", "/HM", "mm", "/MS", "ss"]);
170
174
  const FMT_HHmmss_ALT = defFormat(["HH", "mm", "ss"]);
171
- const FMT_hms = defFormat(["h", ":", "mm", ":", "ss", " ", "A"]);
175
+ const FMT_hms = defFormat(["h", "/HM", "mm", "/MS", "ss", " ", "A"]);
172
176
  const FMT_yyyyMMdd_HHmmss = defFormat(
173
177
  ["yyyy", "MM", "dd", "-", "HH", "mm", "ss"]
174
178
  );
package/i18n/en.js CHANGED
@@ -14,7 +14,6 @@ const EN_SHORT = {
14
14
  "Dec"
15
15
  ],
16
16
  days: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
17
- sepHM: ".",
18
17
  date: ["dd", "/DM", "MM", "/MY", "yyyy"],
19
18
  time: ["h", "/HM", "mm", " ", "a"],
20
19
  units: {
@@ -57,7 +56,6 @@ const EN_LONG = {
57
56
  ],
58
57
  sepDM: " ",
59
58
  sepMY: " ",
60
- sepHM: ".",
61
59
  time: ["h", "/HM", "mm", " ", "a"],
62
60
  units: {
63
61
  y: { s: "year", p: "years" },
package/i18n.js CHANGED
@@ -6,6 +6,7 @@ const __prepLocale = (spec) => {
6
6
  sepDM: "/",
7
7
  sepMY: "/",
8
8
  sepHM: ":",
9
+ sepMS: ":",
9
10
  date: ["E", "/ED", "d", "/DM", "MMM", "/MY", "yyyy"],
10
11
  time: ["H", "/HM", "mm"],
11
12
  ...spec
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/date",
3
- "version": "2.7.83",
3
+ "version": "2.8.1",
4
4
  "description": "Datetime types, relative dates, math, iterators, composable formatters, locales",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -135,5 +135,5 @@
135
135
  "thi.ng": {
136
136
  "year": 2020
137
137
  },
138
- "gitHead": "8ddf86ea0a1e658ddbf19cc645b29d0c176e29c4\n"
138
+ "gitHead": "4eaee6aed1a23312217b85bbb1285c754ba1b446\n"
139
139
  }