date-vir 7.4.0 → 7.4.2
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/dist/date-operations/combine-dates.js +3 -3
- package/dist/date-operations/date-position.d.ts +22 -22
- package/dist/date-operations/date-position.js +17 -17
- package/dist/duration-shape.d.ts +1 -5
- package/dist/duration-shape.js +3 -3
- package/dist/formatting/html-input.js +1 -1
- package/dist/formatting/string-format-types.d.ts +1 -1
- package/dist/formatting/string-format-types.js +6 -6
- package/dist/full-date/full-date-shape.d.ts +23 -972
- package/dist/full-date/full-date-shape.js +9 -9
- package/dist/full-date/string-parsing.js +13 -1
- package/package.json +10 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dayOfMonthBounds, hourBounds, millisecondsBounds, minuteBounds, monthNumberBounds, secondBounds, } from '@date-vir/duration';
|
|
2
|
-
import {
|
|
2
|
+
import { defineShape, enumShape, intersectShape, rangeShape } from 'object-shape-tester';
|
|
3
3
|
import { Timezone, utcTimezone } from '../timezone/timezones.js';
|
|
4
4
|
/**
|
|
5
5
|
* Time part of {@link FullDate} represented in a shape definition.
|
|
@@ -8,13 +8,13 @@ import { Timezone, utcTimezone } from '../timezone/timezones.js';
|
|
|
8
8
|
*/
|
|
9
9
|
export const timePartShape = defineShape({
|
|
10
10
|
/** Hour of the day in 24 time: 0-23 */
|
|
11
|
-
hour:
|
|
11
|
+
hour: rangeShape({ ...hourBounds, default: hourBounds.min }),
|
|
12
12
|
/** Minute of the hour: 0-59 */
|
|
13
|
-
minute:
|
|
13
|
+
minute: rangeShape({ ...minuteBounds, default: minuteBounds.min }),
|
|
14
14
|
/** Second of the minute: 0-59 */
|
|
15
|
-
second:
|
|
15
|
+
second: rangeShape({ ...secondBounds, default: secondBounds.min }),
|
|
16
16
|
/** Millisecond of the second: 0-999 */
|
|
17
|
-
millisecond:
|
|
17
|
+
millisecond: rangeShape({ ...millisecondsBounds, default: millisecondsBounds.min }),
|
|
18
18
|
/** The timezone that this date/time is meant for / originated from. */
|
|
19
19
|
timezone: enumShape(Timezone, utcTimezone),
|
|
20
20
|
});
|
|
@@ -31,15 +31,15 @@ export const datePartShape = defineShape({
|
|
|
31
31
|
*/
|
|
32
32
|
year: 2023,
|
|
33
33
|
/** A month of the year: 1-12 */
|
|
34
|
-
month:
|
|
34
|
+
month: rangeShape({ ...monthNumberBounds, default: monthNumberBounds.min }),
|
|
35
35
|
/** A day of the month: 1-31 depending on the month */
|
|
36
|
-
day:
|
|
36
|
+
day: rangeShape({ ...dayOfMonthBounds, default: dayOfMonthBounds.min }),
|
|
37
37
|
/** The timezone that this date/time is meant for / originated from. */
|
|
38
|
-
timezone: utcTimezone,
|
|
38
|
+
timezone: enumShape(Timezone, utcTimezone),
|
|
39
39
|
});
|
|
40
40
|
/**
|
|
41
41
|
* The complete {@link FullDate} represented in a shape definition.
|
|
42
42
|
*
|
|
43
43
|
* @category Shape
|
|
44
44
|
*/
|
|
45
|
-
export const fullDateShape = defineShape(
|
|
45
|
+
export const fullDateShape = defineShape(intersectShape(datePartShape, timePartShape));
|
|
@@ -22,6 +22,18 @@ const knownStringFormats = [
|
|
|
22
22
|
// padded hour
|
|
23
23
|
// Sat, 01 Jun 2025 6:23:21 +0000 (UTC)
|
|
24
24
|
'ccc, d LLL y HH:mm:ss ZZZ (z)',
|
|
25
|
+
// no padding
|
|
26
|
+
// Sat, 1 Jun 2025 6:23:21 +0000
|
|
27
|
+
'ccc, d LLL y H:mm:ss ZZZ',
|
|
28
|
+
// all padding
|
|
29
|
+
// Sat, 01 Jun 2025 06:23:21 +0000
|
|
30
|
+
'ccc, dd LLL y HH:mm:ss ZZZ',
|
|
31
|
+
// padded day
|
|
32
|
+
// Sat, 01 Jun 2025 6:23:21 +0000
|
|
33
|
+
'ccc, dd LLL y H:mm:ss ZZZ',
|
|
34
|
+
// padded hour
|
|
35
|
+
// Sat, 01 Jun 2025 6:23:21 +0000
|
|
36
|
+
'ccc, d LLL y HH:mm:ss ZZZ',
|
|
25
37
|
];
|
|
26
38
|
/**
|
|
27
39
|
* Tries extra known formats for parsing date strings, even those that browsers do not natively
|
|
@@ -36,7 +48,7 @@ export function parseDateString(dateString, timezone) {
|
|
|
36
48
|
}
|
|
37
49
|
let finalizedDateTime;
|
|
38
50
|
knownStringFormats.some((format) => {
|
|
39
|
-
const dateTimeAttempt = DateTime.fromFormat(dateString, format, { zone: timezone });
|
|
51
|
+
const dateTimeAttempt = DateTime.fromFormat(dateString.trim(), format, { zone: timezone });
|
|
40
52
|
if (!dateTimeAttempt.isValid) {
|
|
41
53
|
return false;
|
|
42
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "date-vir",
|
|
3
|
-
"version": "7.4.
|
|
3
|
+
"version": "7.4.2",
|
|
4
4
|
"description": "Easy and explicit dates and times.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"date",
|
|
@@ -34,26 +34,26 @@
|
|
|
34
34
|
"test:docs": "virmator docs check"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@augment-vir/assert": "^31.
|
|
38
|
-
"@augment-vir/common": "^31.
|
|
39
|
-
"@date-vir/duration": "^7.4.
|
|
40
|
-
"@types/luxon": "^3.
|
|
37
|
+
"@augment-vir/assert": "^31.33.0",
|
|
38
|
+
"@augment-vir/common": "^31.33.0",
|
|
39
|
+
"@date-vir/duration": "^7.4.2",
|
|
40
|
+
"@types/luxon": "^3.7.1",
|
|
41
41
|
"luxon": "^3.7.1",
|
|
42
|
-
"object-shape-tester": "^
|
|
42
|
+
"object-shape-tester": "^6.1.1",
|
|
43
43
|
"type-fest": "^4.41.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@augment-vir/test": "^31.
|
|
46
|
+
"@augment-vir/test": "^31.33.0",
|
|
47
47
|
"@web/dev-server-esbuild": "^1.0.4",
|
|
48
48
|
"@web/test-runner": "^0.20.2",
|
|
49
49
|
"@web/test-runner-commands": "^0.9.0",
|
|
50
50
|
"@web/test-runner-playwright": "^0.11.1",
|
|
51
51
|
"@web/test-runner-visual-regression": "^0.10.0",
|
|
52
|
-
"element-vir": "^26.
|
|
52
|
+
"element-vir": "^26.9.0",
|
|
53
53
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
54
54
|
"markdown-code-example-inserter": "^3.0.3",
|
|
55
|
-
"typedoc": "^0.28.
|
|
56
|
-
"typescript": "^5.
|
|
55
|
+
"typedoc": "^0.28.12",
|
|
56
|
+
"typescript": "^5.9.2"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=22"
|