date-vir 5.3.1 → 6.0.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/LICENSE-MIT +1 -1
- package/README.md +28 -28
- package/dist/date-operations/calculate-relative-date.d.ts +17 -0
- package/dist/{esm/date-operations → date-operations}/calculate-relative-date.js +10 -1
- package/dist/date-operations/combine-dates.d.ts +43 -0
- package/dist/{esm/date-operations → date-operations}/combine-dates.js +6 -4
- package/dist/date-operations/diff-dates.d.ts +95 -0
- package/dist/date-operations/diff-dates.js +124 -0
- package/dist/extra-utils/has-date-props.d.ts +35 -0
- package/dist/extra-utils/has-date-props.js +46 -0
- package/dist/extra-utils/js-date-conversion.d.ts +26 -0
- package/dist/extra-utils/js-date-conversion.js +28 -0
- package/dist/extra-utils/now.d.ts +56 -0
- package/dist/extra-utils/now.js +68 -0
- package/dist/extra-utils/override-date.d.ts +27 -0
- package/dist/extra-utils/override-date.js +27 -0
- package/dist/extra-utils/zero.d.ts +99 -0
- package/dist/extra-utils/zero.js +94 -0
- package/dist/formatting/formatted-string.d.ts +58 -0
- package/dist/formatting/formatted-string.js +73 -0
- package/dist/formatting/html-input.d.ts +30 -0
- package/dist/formatting/html-input.js +47 -0
- package/dist/formatting/relative-string.d.ts +53 -0
- package/dist/formatting/relative-string.js +93 -0
- package/dist/formatting/simple-strings.d.ts +187 -0
- package/dist/formatting/simple-strings.js +120 -0
- package/dist/formatting/string-format-types.d.ts +59 -0
- package/dist/formatting/string-format-types.js +19 -0
- package/dist/formatting/timestamp.d.ts +51 -0
- package/dist/formatting/timestamp.js +61 -0
- package/dist/full-date/create-full-date.d.ts +91 -0
- package/dist/full-date/create-full-date.js +142 -0
- package/dist/full-date/date-like.d.ts +9 -0
- package/dist/{esm/full-date → full-date}/format-presets.d.ts +4 -2
- package/dist/{esm/full-date → full-date}/format-presets.js +4 -2
- package/dist/full-date/full-date-parts.d.ts +48 -0
- package/dist/full-date/full-date-parts.js +45 -0
- package/dist/full-date/full-date-shape.d.ts +106 -0
- package/dist/{esm/full-date → full-date}/full-date-shape.js +15 -22
- package/dist/full-date/is-valid-full-date.d.ts +21 -0
- package/dist/full-date/is-valid-full-date.js +38 -0
- package/dist/full-date/luxon-date-time-conversion.d.ts +19 -0
- package/dist/{esm/full-date → full-date}/luxon-date-time-conversion.js +10 -6
- package/dist/full-date/parsing.d.ts +33 -0
- package/dist/full-date/parsing.js +47 -0
- package/dist/full-date/string-parsing.d.ts +9 -0
- package/dist/{esm/full-date → full-date}/string-parsing.js +6 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +27 -0
- package/dist/locales.d.ts +6 -0
- package/dist/locales.js +7 -0
- package/dist/timezone/timezone-checks.d.ts +21 -0
- package/dist/timezone/timezone-checks.js +34 -0
- package/dist/{esm/timezone → timezone}/timezone-names.d.ts +11 -5
- package/dist/{esm/timezone → timezone}/timezone-names.js +11 -3
- package/dist/timezone/timezones.d.ts +42 -0
- package/dist/timezone/timezones.js +31 -0
- package/package.json +30 -48
- package/cspell.config.cjs +0 -13
- package/dist/cjs/date-operations/calculate-relative-date.js +0 -12
- package/dist/cjs/date-operations/combine-dates.js +0 -50
- package/dist/cjs/date-operations/diff-dates.js +0 -105
- package/dist/cjs/duration/duration-unit.js +0 -41
- package/dist/cjs/duration/duration-utils.js +0 -42
- package/dist/cjs/duration/duration.js +0 -2
- package/dist/cjs/extra-utils/date-transforms.js +0 -8
- package/dist/cjs/extra-utils/has-date-props.js +0 -25
- package/dist/cjs/extra-utils/js-date-conversion.js +0 -8
- package/dist/cjs/extra-utils/now.js +0 -22
- package/dist/cjs/extra-utils/zero.js +0 -31
- package/dist/cjs/formatting/formatted-string.js +0 -34
- package/dist/cjs/formatting/html-input.js +0 -37
- package/dist/cjs/formatting/relative-string.js +0 -77
- package/dist/cjs/formatting/simple-strings.js +0 -58
- package/dist/cjs/formatting/string-format-types.js +0 -9
- package/dist/cjs/formatting/timestamp.js +0 -21
- package/dist/cjs/full-date/create-full-date.js +0 -81
- package/dist/cjs/full-date/date-like.js +0 -2
- package/dist/cjs/full-date/format-presets.js +0 -32
- package/dist/cjs/full-date/full-date-shape.js +0 -54
- package/dist/cjs/full-date/is-valid-full-date.js +0 -28
- package/dist/cjs/full-date/luxon-date-time-conversion.js +0 -43
- package/dist/cjs/full-date/parsing.js +0 -48
- package/dist/cjs/full-date/string-parsing.js +0 -33
- package/dist/cjs/index.js +0 -44
- package/dist/cjs/locales.js +0 -5
- package/dist/cjs/timezone/timezone-checks.js +0 -34
- package/dist/cjs/timezone/timezone-names.js +0 -479
- package/dist/cjs/timezone/timezones.js +0 -14
- package/dist/esm/date-operations/calculate-relative-date.d.ts +0 -8
- package/dist/esm/date-operations/combine-dates.d.ts +0 -35
- package/dist/esm/date-operations/diff-dates.d.ts +0 -66
- package/dist/esm/date-operations/diff-dates.js +0 -100
- package/dist/esm/duration/duration-unit.d.ts +0 -27
- package/dist/esm/duration/duration-unit.js +0 -38
- package/dist/esm/duration/duration-utils.d.ts +0 -11
- package/dist/esm/duration/duration-utils.js +0 -37
- package/dist/esm/duration/duration.d.ts +0 -32
- package/dist/esm/duration/duration.js +0 -1
- package/dist/esm/extra-utils/date-transforms.d.ts +0 -4
- package/dist/esm/extra-utils/date-transforms.js +0 -4
- package/dist/esm/extra-utils/has-date-props.d.ts +0 -9
- package/dist/esm/extra-utils/has-date-props.js +0 -20
- package/dist/esm/extra-utils/js-date-conversion.d.ts +0 -2
- package/dist/esm/extra-utils/js-date-conversion.js +0 -4
- package/dist/esm/extra-utils/now.d.ts +0 -5
- package/dist/esm/extra-utils/now.js +0 -16
- package/dist/esm/extra-utils/zero.d.ts +0 -31
- package/dist/esm/extra-utils/zero.js +0 -26
- package/dist/esm/formatting/formatted-string.d.ts +0 -14
- package/dist/esm/formatting/formatted-string.js +0 -29
- package/dist/esm/formatting/html-input.d.ts +0 -19
- package/dist/esm/formatting/html-input.js +0 -33
- package/dist/esm/formatting/relative-string.d.ts +0 -31
- package/dist/esm/formatting/relative-string.js +0 -73
- package/dist/esm/formatting/simple-strings.d.ts +0 -71
- package/dist/esm/formatting/simple-strings.js +0 -51
- package/dist/esm/formatting/string-format-types.d.ts +0 -7
- package/dist/esm/formatting/string-format-types.js +0 -5
- package/dist/esm/formatting/timestamp.d.ts +0 -6
- package/dist/esm/formatting/timestamp.js +0 -16
- package/dist/esm/full-date/create-full-date.d.ts +0 -21
- package/dist/esm/full-date/create-full-date.js +0 -73
- package/dist/esm/full-date/date-like.d.ts +0 -5
- package/dist/esm/full-date/full-date-shape.d.ts +0 -80
- package/dist/esm/full-date/is-valid-full-date.d.ts +0 -5
- package/dist/esm/full-date/is-valid-full-date.js +0 -22
- package/dist/esm/full-date/luxon-date-time-conversion.d.ts +0 -15
- package/dist/esm/full-date/parsing.d.ts +0 -27
- package/dist/esm/full-date/parsing.js +0 -43
- package/dist/esm/full-date/string-parsing.d.ts +0 -3
- package/dist/esm/index.d.ts +0 -28
- package/dist/esm/index.js +0 -28
- package/dist/esm/locales.d.ts +0 -1
- package/dist/esm/locales.js +0 -2
- package/dist/esm/timezone/timezone-checks.d.ts +0 -17
- package/dist/esm/timezone/timezone-checks.js +0 -29
- package/dist/esm/timezone/timezones.d.ts +0 -480
- package/dist/esm/timezone/timezones.js +0 -11
- package/public/index.css +0 -7
- /package/dist/{esm/full-date → full-date}/date-like.js +0 -0
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { DateTime } from 'luxon';
|
|
2
|
-
import { isRunTimeType } from 'run-time-assertions';
|
|
3
|
-
import { createFullDate } from './create-full-date';
|
|
4
|
-
import { parseLuxonDateTime } from './luxon-date-time-conversion';
|
|
5
|
-
/**
|
|
6
|
-
* Parses any strangely formatted dateString using the given formatString and timezone.
|
|
7
|
-
*
|
|
8
|
-
* This is much more flexible than createFullDate but createFullDate should be preferred in
|
|
9
|
-
* situations where it works.
|
|
10
|
-
*
|
|
11
|
-
* The formatString input is passed to Luxon. All format options are listed here:
|
|
12
|
-
* https://moment.github.io/luxon/#/parsing?id=table-of-tokens
|
|
13
|
-
*/
|
|
14
|
-
export function parseStrangeString({ dateString, formatString, timezone, }) {
|
|
15
|
-
try {
|
|
16
|
-
const dateTime = DateTime.fromFormat(dateString, formatString, {
|
|
17
|
-
zone: timezone,
|
|
18
|
-
setZone: true,
|
|
19
|
-
});
|
|
20
|
-
return parseLuxonDateTime(dateTime);
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
throw new Error(`Failed to parse string '${dateString}' with format '${formatString}'`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Read either an HTMLInputElement's value directly, or the value string retrieved from an
|
|
28
|
-
* HTMLInputElement. Handles both type="date" and type="time" <input> elements.
|
|
29
|
-
*/
|
|
30
|
-
export function parseInputElementValue(elementOrValue, timezone) {
|
|
31
|
-
if (!elementOrValue) {
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
const value = isRunTimeType(elementOrValue, 'string')
|
|
35
|
-
? elementOrValue
|
|
36
|
-
: elementOrValue.value;
|
|
37
|
-
try {
|
|
38
|
-
return createFullDate(value, timezone);
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
}
|
package/dist/esm/index.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export * from './date-operations/calculate-relative-date';
|
|
2
|
-
export * from './date-operations/combine-dates';
|
|
3
|
-
export * from './date-operations/diff-dates';
|
|
4
|
-
export * from './duration/duration';
|
|
5
|
-
export * from './duration/duration-unit';
|
|
6
|
-
export * from './duration/duration-utils';
|
|
7
|
-
export * from './extra-utils/date-transforms';
|
|
8
|
-
export * from './extra-utils/has-date-props';
|
|
9
|
-
export * from './extra-utils/js-date-conversion';
|
|
10
|
-
export * from './extra-utils/now';
|
|
11
|
-
export * from './extra-utils/zero';
|
|
12
|
-
export * from './formatting/formatted-string';
|
|
13
|
-
export * from './formatting/html-input';
|
|
14
|
-
export * from './formatting/relative-string';
|
|
15
|
-
export * from './formatting/simple-strings';
|
|
16
|
-
export * from './formatting/string-format-types';
|
|
17
|
-
export * from './formatting/timestamp';
|
|
18
|
-
export * from './full-date/create-full-date';
|
|
19
|
-
export * from './full-date/date-like';
|
|
20
|
-
export * from './full-date/format-presets';
|
|
21
|
-
export * from './full-date/full-date-shape';
|
|
22
|
-
export * from './full-date/is-valid-full-date';
|
|
23
|
-
export * from './full-date/luxon-date-time-conversion';
|
|
24
|
-
export * from './full-date/parsing';
|
|
25
|
-
export * from './locales';
|
|
26
|
-
export * from './timezone/timezone-checks';
|
|
27
|
-
export * from './timezone/timezone-names';
|
|
28
|
-
export * from './timezone/timezones';
|
package/dist/esm/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export * from './date-operations/calculate-relative-date';
|
|
2
|
-
export * from './date-operations/combine-dates';
|
|
3
|
-
export * from './date-operations/diff-dates';
|
|
4
|
-
export * from './duration/duration';
|
|
5
|
-
export * from './duration/duration-unit';
|
|
6
|
-
export * from './duration/duration-utils';
|
|
7
|
-
export * from './extra-utils/date-transforms';
|
|
8
|
-
export * from './extra-utils/has-date-props';
|
|
9
|
-
export * from './extra-utils/js-date-conversion';
|
|
10
|
-
export * from './extra-utils/now';
|
|
11
|
-
export * from './extra-utils/zero';
|
|
12
|
-
export * from './formatting/formatted-string';
|
|
13
|
-
export * from './formatting/html-input';
|
|
14
|
-
export * from './formatting/relative-string';
|
|
15
|
-
export * from './formatting/simple-strings';
|
|
16
|
-
export * from './formatting/string-format-types';
|
|
17
|
-
export * from './formatting/timestamp';
|
|
18
|
-
export * from './full-date/create-full-date';
|
|
19
|
-
export * from './full-date/date-like';
|
|
20
|
-
export * from './full-date/format-presets';
|
|
21
|
-
export * from './full-date/full-date-shape';
|
|
22
|
-
export * from './full-date/is-valid-full-date';
|
|
23
|
-
export * from './full-date/luxon-date-time-conversion';
|
|
24
|
-
export * from './full-date/parsing';
|
|
25
|
-
export * from './locales';
|
|
26
|
-
export * from './timezone/timezone-checks';
|
|
27
|
-
export * from './timezone/timezone-names';
|
|
28
|
-
export * from './timezone/timezones';
|
package/dist/esm/locales.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const userLocale: string;
|
package/dist/esm/locales.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Timezone } from './timezone-names';
|
|
2
|
-
/**
|
|
3
|
-
* Asserts that the given timezoneName is a valid timezone name.
|
|
4
|
-
*
|
|
5
|
-
* Note that this may actually allow names beyond what is currently in the exact TimezoneName type,
|
|
6
|
-
* because this function uses luxon to check that it is able to generate a date with the given
|
|
7
|
-
* timezone, regardless of whether it's in our typed list or not.
|
|
8
|
-
*/
|
|
9
|
-
export declare function assertValidTimezone(potentialTimezoneName: string): asserts potentialTimezoneName is Timezone;
|
|
10
|
-
/**
|
|
11
|
-
* Checks that the given timezoneName is a valid timezone name.
|
|
12
|
-
*
|
|
13
|
-
* Note that this may actually allow names beyond what is currently in the exact TimezoneName type,
|
|
14
|
-
* because this function uses luxon to check that it is able to generate a date with the given
|
|
15
|
-
* timezone, regardless of whether it's in our typed list or not.
|
|
16
|
-
*/
|
|
17
|
-
export declare function isValidTimezone(potentialTimezoneName: string): potentialTimezoneName is Timezone;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Info } from 'luxon';
|
|
2
|
-
/**
|
|
3
|
-
* Asserts that the given timezoneName is a valid timezone name.
|
|
4
|
-
*
|
|
5
|
-
* Note that this may actually allow names beyond what is currently in the exact TimezoneName type,
|
|
6
|
-
* because this function uses luxon to check that it is able to generate a date with the given
|
|
7
|
-
* timezone, regardless of whether it's in our typed list or not.
|
|
8
|
-
*/
|
|
9
|
-
export function assertValidTimezone(potentialTimezoneName) {
|
|
10
|
-
if (!Info.isValidIANAZone(potentialTimezoneName)) {
|
|
11
|
-
throw new Error(`'${potentialTimezoneName}' is not a valid time zone`);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Checks that the given timezoneName is a valid timezone name.
|
|
16
|
-
*
|
|
17
|
-
* Note that this may actually allow names beyond what is currently in the exact TimezoneName type,
|
|
18
|
-
* because this function uses luxon to check that it is able to generate a date with the given
|
|
19
|
-
* timezone, regardless of whether it's in our typed list or not.
|
|
20
|
-
*/
|
|
21
|
-
export function isValidTimezone(potentialTimezoneName) {
|
|
22
|
-
try {
|
|
23
|
-
assertValidTimezone(potentialTimezoneName);
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
}
|