date-vir 7.3.1 → 7.4.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/README.md +1 -1
- package/dist/date-operations/calculate-relative-date.d.ts +3 -3
- package/dist/date-operations/combine-dates.d.ts +3 -3
- package/dist/date-operations/date-position.d.ts +1 -1
- package/dist/date-operations/diff-dates.d.ts +1 -1
- package/dist/duration-shape.d.ts +11 -0
- package/dist/duration-shape.js +12 -0
- package/dist/extra-utils/has-date-props.d.ts +1 -1
- package/dist/extra-utils/js-date-conversion.d.ts +1 -1
- package/dist/extra-utils/now.d.ts +3 -3
- package/dist/extra-utils/override-date.d.ts +2 -2
- package/dist/extra-utils/zero.d.ts +2 -2
- package/dist/formatting/html-input.d.ts +2 -2
- package/dist/formatting/relative-string.d.ts +2 -2
- package/dist/formatting/relative-string.js +2 -1
- package/dist/formatting/simple-strings.d.ts +3 -3
- package/dist/formatting/timestamp.d.ts +2 -2
- package/dist/full-date/create-full-date.d.ts +3 -3
- package/dist/full-date/date-like.d.ts +3 -3
- package/dist/full-date/full-date-shape.d.ts +2 -2
- package/dist/full-date/is-valid-full-date.d.ts +2 -2
- package/dist/full-date/luxon-date-time-conversion.d.ts +2 -2
- package/dist/full-date/parsing.d.ts +2 -2
- package/dist/full-date/string-parsing.d.ts +1 -1
- package/dist/full-date/string-parsing.js +12 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/timezone/timezone-checks.d.ts +1 -1
- package/dist/timezone/timezones.d.ts +1 -1
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Full docs: http://electrovir.github.io/date-vir
|
|
|
9
9
|
<!-- example-link: src/readme-examples/full-date.example.ts -->
|
|
10
10
|
|
|
11
11
|
```TypeScript
|
|
12
|
-
import {FullDate, utcTimezone} from 'date-vir';
|
|
12
|
+
import {type FullDate, utcTimezone} from 'date-vir';
|
|
13
13
|
|
|
14
14
|
const myDate: FullDate = {
|
|
15
15
|
year: 2023,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { FullDate } from '../full-date/full-date-shape.js';
|
|
3
|
-
import { Timezone } from '../timezone/timezones.js';
|
|
1
|
+
import { type AnyDuration } from '@date-vir/duration';
|
|
2
|
+
import { type FullDate } from '../full-date/full-date-shape.js';
|
|
3
|
+
import { type Timezone } from '../timezone/timezones.js';
|
|
4
4
|
/**
|
|
5
5
|
* Calculates a new date starting at the given fullDate and adding the given offsets. Offsets can be
|
|
6
6
|
* negative to go backwards in time.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { DatePart, FullDate, TimePart } from '../full-date/full-date-shape.js';
|
|
3
|
-
import type
|
|
1
|
+
import { type FullDatePart } from '../full-date/full-date-parts.js';
|
|
2
|
+
import { type DatePart, type FullDate, type TimePart } from '../full-date/full-date-shape.js';
|
|
3
|
+
import { type Timezone } from '../timezone/timezones.js';
|
|
4
4
|
/**
|
|
5
5
|
* An object containing date and/or time parts or neither. Used for {@link combineDateParts}
|
|
6
6
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DateUnit } from '@date-vir/duration';
|
|
2
2
|
import { type FullDate } from '../full-date/full-date-shape.js';
|
|
3
|
-
import { Timezone } from '../timezone/timezones.js';
|
|
3
|
+
import { type Timezone } from '../timezone/timezones.js';
|
|
4
4
|
/**
|
|
5
5
|
* Get the {@link DateUnit} value of a {@link FullDate}.
|
|
6
6
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type DurationBySelection, type DurationUnitSelection, type RoundOptions } from '@date-vir/duration';
|
|
2
|
-
import { FullDate } from '../full-date/full-date-shape.js';
|
|
2
|
+
import { type FullDate } from '../full-date/full-date-shape.js';
|
|
3
3
|
/**
|
|
4
4
|
* Diffs two dates and returns the diff in the specified unit or units. When a multiple units are
|
|
5
5
|
* provided with the `units` input property, an array is returned with the full diff duration
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DurationUnit } from '@date-vir/duration';
|
|
2
|
+
/**
|
|
3
|
+
* A shape definition for `AnyDuration`.
|
|
4
|
+
*
|
|
5
|
+
* @category Duration
|
|
6
|
+
*/
|
|
7
|
+
export declare const anyDurationShape: import("object-shape-tester").ShapeIndexedKeys<[{
|
|
8
|
+
keys: import("object-shape-tester").ShapeEnum<readonly [typeof DurationUnit]>;
|
|
9
|
+
values: number;
|
|
10
|
+
required: false;
|
|
11
|
+
}]>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DurationUnit } from '@date-vir/duration';
|
|
2
|
+
import { enumShape, indexedKeys } from 'object-shape-tester';
|
|
3
|
+
/**
|
|
4
|
+
* A shape definition for `AnyDuration`.
|
|
5
|
+
*
|
|
6
|
+
* @category Duration
|
|
7
|
+
*/
|
|
8
|
+
export const anyDurationShape = indexedKeys({
|
|
9
|
+
keys: enumShape(DurationUnit),
|
|
10
|
+
values: -1,
|
|
11
|
+
required: false,
|
|
12
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type PartialWithUndefined, type SetRequiredAndNotNull } from '@augment-vir/common';
|
|
2
2
|
import { type FullDate } from '../full-date/full-date-shape.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type Timezone } from '../timezone/timezones.js';
|
|
4
4
|
/**
|
|
5
5
|
* Checks that the input has all the requested {@link FullDate} keys.
|
|
6
6
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FullDate } from '../full-date/full-date-shape.js';
|
|
1
|
+
import { type FullDate } from '../full-date/full-date-shape.js';
|
|
2
2
|
/**
|
|
3
3
|
* Convert a {@link FullDate} from a built-in JS
|
|
4
4
|
* [`Date`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UtcIsoString } from '../formatting/string-format-types.js';
|
|
2
|
-
import { FullDate } from '../full-date/full-date-shape.js';
|
|
3
|
-
import { Timezone, UtcTimezone } from '../timezone/timezones.js';
|
|
1
|
+
import { type UtcIsoString } from '../formatting/string-format-types.js';
|
|
2
|
+
import { type FullDate } from '../full-date/full-date-shape.js';
|
|
3
|
+
import { type Timezone, type UtcTimezone } from '../timezone/timezones.js';
|
|
4
4
|
/**
|
|
5
5
|
* Get the time right now as a UTC ISO.
|
|
6
6
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FullDate } from '../full-date/full-date-shape.js';
|
|
2
|
-
import { Timezone } from '../timezone/timezones.js';
|
|
1
|
+
import { type FullDate } from '../full-date/full-date-shape.js';
|
|
2
|
+
import { type Timezone } from '../timezone/timezones.js';
|
|
3
3
|
/**
|
|
4
4
|
* Override the initial provided FullDate with all subsequent FullDate parts.
|
|
5
5
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TimeKey } from '../full-date/full-date-parts.js';
|
|
2
|
-
import { FullDate } from '../full-date/full-date-shape.js';
|
|
3
|
-
import { Timezone } from '../timezone/timezones.js';
|
|
2
|
+
import { type FullDate } from '../full-date/full-date-shape.js';
|
|
3
|
+
import { type Timezone } from '../timezone/timezones.js';
|
|
4
4
|
/**
|
|
5
5
|
* A {@link FullDate} instance that has the lowest, valid, non-negative, value for each property.
|
|
6
6
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FullDatePart } from '../full-date/full-date-parts.js';
|
|
2
|
-
import { DatePart, FullDate } from '../full-date/full-date-shape.js';
|
|
3
|
-
import { DateTimeString, DateTimeWithSeconds, JustDateString, JustTimeString, JustTimeWithSecondsString } from './string-format-types.js';
|
|
2
|
+
import { type DatePart, type FullDate } from '../full-date/full-date-shape.js';
|
|
3
|
+
import { type DateTimeString, type DateTimeWithSeconds, type JustDateString, type JustTimeString, type JustTimeWithSecondsString } from './string-format-types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Only the date part of a {@link FullDate}, without timezone.
|
|
6
6
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
-
import { AnyDuration, DurationUnitSelection } from '@date-vir/duration';
|
|
3
|
-
import { FullDate } from '../full-date/full-date-shape.js';
|
|
2
|
+
import { type AnyDuration, type DurationUnitSelection } from '@date-vir/duration';
|
|
3
|
+
import { type FullDate } from '../full-date/full-date-shape.js';
|
|
4
4
|
/**
|
|
5
5
|
* Options for {@link toRelativeString}.
|
|
6
6
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { check } from '@augment-vir/assert';
|
|
2
2
|
import { arrayToObject, filterMap } from '@augment-vir/common';
|
|
3
|
-
import {
|
|
3
|
+
import { convertDuration, DurationUnit, flattenUnitSelection, singularDurationUnitNames, } from '@date-vir/duration';
|
|
4
4
|
import { diffDates } from '../date-operations/diff-dates.js';
|
|
5
5
|
const defaultJustNowThresholds = {
|
|
6
6
|
minutes: 1.5,
|
|
@@ -62,6 +62,7 @@ export function toRelativeString(datesOrDuration, units, options = {}) {
|
|
|
62
62
|
return 'just now';
|
|
63
63
|
}
|
|
64
64
|
else if (options.useOnlyLargestUnit) {
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
65
66
|
if (!unitValues[0]) {
|
|
66
67
|
return '';
|
|
67
68
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { FullDate } from '../full-date/full-date-shape.js';
|
|
3
|
-
import { JustDateString, JustTimeString, JustTimeWithSecondsString } from './string-format-types.js';
|
|
1
|
+
import { type SetOptionalAndNullable } from '@augment-vir/common';
|
|
2
|
+
import { type FullDate } from '../full-date/full-date-shape.js';
|
|
3
|
+
import { type JustDateString, type JustTimeString, type JustTimeWithSecondsString } from './string-format-types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Create a string based on just the date parts of a FullDate.
|
|
6
6
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FullDate } from '../full-date/full-date-shape.js';
|
|
2
|
-
import { UtcIsoString } from './string-format-types.js';
|
|
1
|
+
import { type FullDate } from '../full-date/full-date-shape.js';
|
|
2
|
+
import { type UtcIsoString } from './string-format-types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Convert a FullDate into a unix timestamp with milliseconds.
|
|
5
5
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Timezone, UtcTimezone } from '../timezone/timezones.js';
|
|
2
|
-
import { DateLike } from './date-like.js';
|
|
3
|
-
import { FullDate } from './full-date-shape.js';
|
|
1
|
+
import { type Timezone, type UtcTimezone } from '../timezone/timezones.js';
|
|
2
|
+
import { type DateLike } from './date-like.js';
|
|
3
|
+
import { type FullDate } from './full-date-shape.js';
|
|
4
4
|
/**
|
|
5
5
|
* Parses the given {@link DateLike} and converts it into a {@link FullDate} instance with the user's
|
|
6
6
|
* current timezone.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DateTime } from 'luxon';
|
|
2
|
-
import { Timezone } from '../timezone/timezones.js';
|
|
3
|
-
import { FullDate } from './full-date-shape.js';
|
|
1
|
+
import { type DateTime } from 'luxon';
|
|
2
|
+
import { type Timezone } from '../timezone/timezones.js';
|
|
3
|
+
import { type FullDate } from './full-date-shape.js';
|
|
4
4
|
/**
|
|
5
5
|
* Types that can be converted into {@link FullDate} instances.
|
|
6
6
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Overwrite, type SetRequired } from '@augment-vir/common';
|
|
1
|
+
import { type Overwrite, type SetRequired } from '@augment-vir/common';
|
|
2
2
|
import { type DayOfMonth, type Hour, type Minute, type MonthNumber, type Second } from '@date-vir/duration';
|
|
3
|
-
import type
|
|
3
|
+
import { type Simplify } from 'type-fest';
|
|
4
4
|
import { Timezone } from '../timezone/timezones.js';
|
|
5
5
|
/**
|
|
6
6
|
* Time part of {@link FullDate} represented in a shape definition.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Timezone } from '../timezone/timezones.js';
|
|
2
|
-
import { FullDate } from './full-date-shape.js';
|
|
1
|
+
import { type Timezone } from '../timezone/timezones.js';
|
|
2
|
+
import { type FullDate } from './full-date-shape.js';
|
|
3
3
|
/**
|
|
4
4
|
* Asserts that the input is a valid {@link FullDate}.
|
|
5
5
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DateTime } from 'luxon';
|
|
2
|
-
import { Timezone } from '../timezone/timezones.js';
|
|
3
|
-
import { FullDate } from './full-date-shape.js';
|
|
2
|
+
import { type Timezone } from '../timezone/timezones.js';
|
|
3
|
+
import { type FullDate } from './full-date-shape.js';
|
|
4
4
|
/**
|
|
5
5
|
* Converts a {@link FullDate} object into a Luxon DateTime library. This is only needed if you need
|
|
6
6
|
* complex operations on dates. It does, however, internally power a lot of date-vir functionality
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Timezone } from '../timezone/timezones.js';
|
|
2
|
-
import { FullDate } from './full-date-shape.js';
|
|
1
|
+
import { type Timezone } from '../timezone/timezones.js';
|
|
2
|
+
import { type FullDate } from './full-date-shape.js';
|
|
3
3
|
/**
|
|
4
4
|
* Parses any date string into a {@link FullDate} using the specified pattern and timezone. Prefer
|
|
5
5
|
* using {@link createFullDate} if possible.
|
|
@@ -10,6 +10,18 @@ const knownStringFormats = [
|
|
|
10
10
|
'LLL-y',
|
|
11
11
|
// january-2021
|
|
12
12
|
'LLLL-y',
|
|
13
|
+
// no padding
|
|
14
|
+
// Sat, 1 Jun 2025 6:23:21 +0000 (UTC)
|
|
15
|
+
'ccc, d LLL y H:mm:ss ZZZ (z)',
|
|
16
|
+
// all padding
|
|
17
|
+
// Sat, 01 Jun 2025 06:23:21 +0000 (UTC)
|
|
18
|
+
'ccc, dd LLL y HH:mm:ss ZZZ (z)',
|
|
19
|
+
// padded day
|
|
20
|
+
// Sat, 01 Jun 2025 6:23:21 +0000 (UTC)
|
|
21
|
+
'ccc, dd LLL y H:mm:ss ZZZ (z)',
|
|
22
|
+
// padded hour
|
|
23
|
+
// Sat, 01 Jun 2025 6:23:21 +0000 (UTC)
|
|
24
|
+
'ccc, d LLL y HH:mm:ss ZZZ (z)',
|
|
13
25
|
];
|
|
14
26
|
/**
|
|
15
27
|
* Tries extra known formats for parsing date strings, even those that browsers do not natively
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './date-operations/calculate-relative-date.js';
|
|
|
2
2
|
export * from './date-operations/combine-dates.js';
|
|
3
3
|
export * from './date-operations/date-position.js';
|
|
4
4
|
export * from './date-operations/diff-dates.js';
|
|
5
|
+
export * from './duration-shape.js';
|
|
5
6
|
export * from './extra-utils/end.js';
|
|
6
7
|
export * from './extra-utils/has-date-props.js';
|
|
7
8
|
export * from './extra-utils/js-date-conversion.js';
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './date-operations/calculate-relative-date.js';
|
|
|
2
2
|
export * from './date-operations/combine-dates.js';
|
|
3
3
|
export * from './date-operations/date-position.js';
|
|
4
4
|
export * from './date-operations/diff-dates.js';
|
|
5
|
+
export * from './duration-shape.js';
|
|
5
6
|
export * from './extra-utils/end.js';
|
|
6
7
|
export * from './extra-utils/has-date-props.js';
|
|
7
8
|
export * from './extra-utils/js-date-conversion.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "date-vir",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
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.
|
|
40
|
-
"@types/luxon": "^3.
|
|
41
|
-
"luxon": "^3.
|
|
42
|
-
"object-shape-tester": "^5.
|
|
43
|
-
"type-fest": "^4.
|
|
37
|
+
"@augment-vir/assert": "^31.28.0",
|
|
38
|
+
"@augment-vir/common": "^31.28.0",
|
|
39
|
+
"@date-vir/duration": "^7.4.0",
|
|
40
|
+
"@types/luxon": "^3.6.2",
|
|
41
|
+
"luxon": "^3.7.1",
|
|
42
|
+
"object-shape-tester": "^5.3.0",
|
|
43
|
+
"type-fest": "^4.41.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@augment-vir/test": "^31.
|
|
46
|
+
"@augment-vir/test": "^31.28.0",
|
|
47
47
|
"@web/dev-server-esbuild": "^1.0.4",
|
|
48
|
-
"@web/test-runner": "^0.20.
|
|
48
|
+
"@web/test-runner": "^0.20.2",
|
|
49
49
|
"@web/test-runner-commands": "^0.9.0",
|
|
50
|
-
"@web/test-runner-playwright": "^0.11.
|
|
50
|
+
"@web/test-runner-playwright": "^0.11.1",
|
|
51
51
|
"@web/test-runner-visual-regression": "^0.10.0",
|
|
52
|
-
"element-vir": "^
|
|
52
|
+
"element-vir": "^26.5.8",
|
|
53
53
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
54
54
|
"markdown-code-example-inserter": "^3.0.3",
|
|
55
|
-
"typedoc": "^0.
|
|
56
|
-
"typescript": "^5.8.
|
|
55
|
+
"typedoc": "^0.28.7",
|
|
56
|
+
"typescript": "^5.8.3"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=22"
|