date-vir 0.0.0 → 0.1.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/LICENSE-CC0 +121 -0
- package/LICENSE-MIT +21 -0
- package/README.md +148 -0
- package/dist/cjs/full-date/calculate-relative-date.js +8 -0
- package/dist/cjs/full-date/create-full-date.js +67 -0
- package/dist/cjs/full-date/date-like.js +2 -0
- package/dist/cjs/full-date/format-presets.js +32 -0
- package/dist/cjs/full-date/full-date-shape.js +33 -0
- package/dist/cjs/full-date/is-valid-full-date.js +24 -0
- package/dist/cjs/full-date/luxon-date-time-conversion.js +43 -0
- package/dist/cjs/full-date/parsing.js +43 -0
- package/dist/cjs/full-date/primitive-conversions.js +74 -0
- package/dist/cjs/full-date/string-format-types.js +2 -0
- package/dist/cjs/index.js +29 -0
- package/dist/cjs/locales.js +5 -0
- package/dist/cjs/timezone/timezone-checks.js +34 -0
- package/dist/cjs/timezone/timezone-names.js +479 -0
- package/dist/cjs/timezone/timezones.js +14 -0
- package/dist/full-date/calculate-relative-date.d.ts +4 -0
- package/dist/full-date/calculate-relative-date.js +8 -0
- package/dist/full-date/create-full-date.d.ts +20 -0
- package/dist/full-date/create-full-date.js +67 -0
- package/dist/full-date/date-like.d.ts +4 -0
- package/dist/full-date/date-like.js +2 -0
- package/dist/full-date/format-presets.d.ts +28 -0
- package/dist/full-date/format-presets.js +32 -0
- package/dist/full-date/full-date-shape.d.ts +65 -0
- package/dist/full-date/full-date-shape.js +33 -0
- package/dist/full-date/is-valid-full-date.d.ts +3 -0
- package/dist/full-date/is-valid-full-date.js +24 -0
- package/dist/full-date/luxon-date-time-conversion.d.ts +14 -0
- package/dist/full-date/luxon-date-time-conversion.js +43 -0
- package/dist/full-date/parsing.d.ts +27 -0
- package/dist/full-date/parsing.js +43 -0
- package/dist/full-date/primitive-conversions.d.ts +42 -0
- package/dist/full-date/primitive-conversions.js +74 -0
- package/dist/full-date/string-format-types.d.ts +4 -0
- package/dist/full-date/string-format-types.js +2 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +29 -0
- package/dist/locales.d.ts +1 -0
- package/dist/locales.js +5 -0
- package/dist/timezone/timezone-checks.d.ts +17 -0
- package/dist/timezone/timezone-checks.js +34 -0
- package/dist/timezone/timezone-names.d.ts +9 -0
- package/dist/timezone/timezone-names.js +479 -0
- package/dist/timezone/timezones.d.ts +479 -0
- package/dist/timezone/timezones.js +14 -0
- package/package.json +72 -10
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatPresets = void 0;
|
|
4
|
+
const luxon_1 = require("luxon");
|
|
5
|
+
/**
|
|
6
|
+
* Format preset re-exported from luxon to be used with toLocaleString. To see examples of all
|
|
7
|
+
* presets, go here: https://moment.github.io/luxon/#/formatting?id=presets
|
|
8
|
+
*/
|
|
9
|
+
exports.formatPresets = {
|
|
10
|
+
DateShort: luxon_1.DateTime.DATE_SHORT,
|
|
11
|
+
DateMed: luxon_1.DateTime.DATE_MED,
|
|
12
|
+
DateMedWithWeekday: luxon_1.DateTime.DATE_MED_WITH_WEEKDAY,
|
|
13
|
+
DateFull: luxon_1.DateTime.DATE_FULL,
|
|
14
|
+
DateHuge: luxon_1.DateTime.DATE_HUGE,
|
|
15
|
+
TimeSimple: luxon_1.DateTime.TIME_SIMPLE,
|
|
16
|
+
TimeWithSeconds: luxon_1.DateTime.TIME_WITH_SECONDS,
|
|
17
|
+
TimeWithShortOffset: luxon_1.DateTime.TIME_WITH_SHORT_OFFSET,
|
|
18
|
+
TimeWithLongOffset: luxon_1.DateTime.TIME_WITH_LONG_OFFSET,
|
|
19
|
+
Time24Simple: luxon_1.DateTime.TIME_24_SIMPLE,
|
|
20
|
+
Time24WithSeconds: luxon_1.DateTime.TIME_24_WITH_SECONDS,
|
|
21
|
+
Time24WithShortOffset: luxon_1.DateTime.TIME_24_WITH_SHORT_OFFSET,
|
|
22
|
+
Time24WithLongOffset: luxon_1.DateTime.TIME_24_WITH_LONG_OFFSET,
|
|
23
|
+
DatetimeShort: luxon_1.DateTime.DATETIME_SHORT,
|
|
24
|
+
DatetimeShortWithSeconds: luxon_1.DateTime.DATETIME_SHORT_WITH_SECONDS,
|
|
25
|
+
DatetimeMed: luxon_1.DateTime.DATETIME_MED,
|
|
26
|
+
DatetimeMedWithSeconds: luxon_1.DateTime.DATETIME_MED_WITH_SECONDS,
|
|
27
|
+
DatetimeMedWithWeekday: luxon_1.DateTime.DATETIME_MED_WITH_WEEKDAY,
|
|
28
|
+
DatetimeFull: luxon_1.DateTime.DATETIME_FULL,
|
|
29
|
+
DatetimeFullWithSeconds: luxon_1.DateTime.DATETIME_FULL_WITH_SECONDS,
|
|
30
|
+
DatetimeHuge: luxon_1.DateTime.DATETIME_HUGE,
|
|
31
|
+
DatetimeHugeWithSeconds: luxon_1.DateTime.DATETIME_HUGE_WITH_SECONDS,
|
|
32
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Overwrite } from '@augment-vir/common';
|
|
2
|
+
import { Timezone } from '../timezone/timezone-names';
|
|
3
|
+
export type WithTimezone = {
|
|
4
|
+
timezone: Timezone;
|
|
5
|
+
};
|
|
6
|
+
export declare const timeOnlyShape: import("object-shape-tester").ShapeDefinition<{
|
|
7
|
+
/** Hour of the day in 24 time: 0-23 */
|
|
8
|
+
hour: number;
|
|
9
|
+
/** Minute of the hour: 0-59 */
|
|
10
|
+
minute: number;
|
|
11
|
+
/** Second of the minute: 0-59 */
|
|
12
|
+
second: number;
|
|
13
|
+
/** Millisecond of the second: 0-999 */
|
|
14
|
+
millisecond: number;
|
|
15
|
+
/** The timezone that this date/time is meant for / originated from. */
|
|
16
|
+
timezone: "UTC";
|
|
17
|
+
}>;
|
|
18
|
+
export type TimeOnly = Overwrite<(typeof timeOnlyShape)['runTimeType'], WithTimezone>;
|
|
19
|
+
export declare const dateOnlyShape: import("object-shape-tester").ShapeDefinition<{
|
|
20
|
+
/**
|
|
21
|
+
* The full, four digit year.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* 2023;
|
|
25
|
+
*/
|
|
26
|
+
year: number;
|
|
27
|
+
/** A month of the year: 1-12 */
|
|
28
|
+
month: number;
|
|
29
|
+
/** A day of the month: 1-31 depending on the month */
|
|
30
|
+
day: number;
|
|
31
|
+
/** The timezone that this date/time is meant for / originated from. */
|
|
32
|
+
timezone: "UTC";
|
|
33
|
+
}>;
|
|
34
|
+
export type DateOnly = Overwrite<(typeof dateOnlyShape)['runTimeType'], WithTimezone>;
|
|
35
|
+
export declare const fullDateShape: import("object-shape-tester").ShapeDefinition<import("object-shape-tester").ShapeAnd<[import("object-shape-tester").ShapeDefinition<{
|
|
36
|
+
/**
|
|
37
|
+
* The full, four digit year.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* 2023;
|
|
41
|
+
*/
|
|
42
|
+
year: number;
|
|
43
|
+
/** A month of the year: 1-12 */
|
|
44
|
+
month: number;
|
|
45
|
+
/** A day of the month: 1-31 depending on the month */
|
|
46
|
+
day: number;
|
|
47
|
+
/** The timezone that this date/time is meant for / originated from. */
|
|
48
|
+
timezone: "UTC";
|
|
49
|
+
}>, import("object-shape-tester").ShapeDefinition<{
|
|
50
|
+
/** Hour of the day in 24 time: 0-23 */
|
|
51
|
+
hour: number;
|
|
52
|
+
/** Minute of the hour: 0-59 */
|
|
53
|
+
minute: number;
|
|
54
|
+
/** Second of the minute: 0-59 */
|
|
55
|
+
second: number;
|
|
56
|
+
/** Millisecond of the second: 0-999 */
|
|
57
|
+
millisecond: number;
|
|
58
|
+
/** The timezone that this date/time is meant for / originated from. */
|
|
59
|
+
timezone: "UTC";
|
|
60
|
+
}>]>>;
|
|
61
|
+
/**
|
|
62
|
+
* A easily serializable (it fits into plain JSON) object that completely defines how a date is to
|
|
63
|
+
* be represented with minimal data.
|
|
64
|
+
*/
|
|
65
|
+
export type FullDate = Overwrite<(typeof fullDateShape)['runTimeType'], WithTimezone>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fullDateShape = exports.dateOnlyShape = exports.timeOnlyShape = void 0;
|
|
4
|
+
const object_shape_tester_1 = require("object-shape-tester");
|
|
5
|
+
const timezones_1 = require("../timezone/timezones");
|
|
6
|
+
exports.timeOnlyShape = (0, object_shape_tester_1.defineShape)({
|
|
7
|
+
/** Hour of the day in 24 time: 0-23 */
|
|
8
|
+
hour: 14,
|
|
9
|
+
/** Minute of the hour: 0-59 */
|
|
10
|
+
minute: 19,
|
|
11
|
+
/** Second of the minute: 0-59 */
|
|
12
|
+
second: 0,
|
|
13
|
+
/** Millisecond of the second: 0-999 */
|
|
14
|
+
millisecond: 870,
|
|
15
|
+
/** The timezone that this date/time is meant for / originated from. */
|
|
16
|
+
timezone: timezones_1.utcTimezone,
|
|
17
|
+
});
|
|
18
|
+
exports.dateOnlyShape = (0, object_shape_tester_1.defineShape)({
|
|
19
|
+
/**
|
|
20
|
+
* The full, four digit year.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* 2023;
|
|
24
|
+
*/
|
|
25
|
+
year: 2023,
|
|
26
|
+
/** A month of the year: 1-12 */
|
|
27
|
+
month: 6,
|
|
28
|
+
/** A day of the month: 1-31 depending on the month */
|
|
29
|
+
day: 5,
|
|
30
|
+
/** The timezone that this date/time is meant for / originated from. */
|
|
31
|
+
timezone: timezones_1.utcTimezone,
|
|
32
|
+
});
|
|
33
|
+
exports.fullDateShape = (0, object_shape_tester_1.defineShape)((0, object_shape_tester_1.and)(exports.dateOnlyShape, exports.timeOnlyShape));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidFullDate = exports.assertIsValidFullDate = void 0;
|
|
4
|
+
const object_shape_tester_1 = require("object-shape-tester");
|
|
5
|
+
const timezone_checks_1 = require("../timezone/timezone-checks");
|
|
6
|
+
const full_date_shape_1 = require("./full-date-shape");
|
|
7
|
+
const luxon_date_time_conversion_1 = require("./luxon-date-time-conversion");
|
|
8
|
+
function assertIsValidFullDate(input) {
|
|
9
|
+
(0, object_shape_tester_1.assertValidShape)(input, full_date_shape_1.fullDateShape);
|
|
10
|
+
(0, timezone_checks_1.assertValidTimezone)(input.timezone);
|
|
11
|
+
/** Check that the input can be converted to a luxon date correctly. */
|
|
12
|
+
(0, luxon_date_time_conversion_1.toLuxonDateTime)(input);
|
|
13
|
+
}
|
|
14
|
+
exports.assertIsValidFullDate = assertIsValidFullDate;
|
|
15
|
+
function isValidFullDate(input) {
|
|
16
|
+
try {
|
|
17
|
+
assertIsValidFullDate(input);
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.isValidFullDate = isValidFullDate;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DateTime } from 'luxon';
|
|
2
|
+
import { FullDate } from './full-date-shape';
|
|
3
|
+
/**
|
|
4
|
+
* Converts a FullDate object into a Luxon DateTime library. This is only needed if you need complex
|
|
5
|
+
* operations on dates. It does, however, internally power a lot of the date-vir functionality as it
|
|
6
|
+
* uses the Luxon library for conversions between timezones.
|
|
7
|
+
*/
|
|
8
|
+
export declare function toLuxonDateTime(fullDateInput: FullDate): DateTime;
|
|
9
|
+
/**
|
|
10
|
+
* Convert a Luxon DateTime object into a DateTime object. Used internally inside of date-vir, but
|
|
11
|
+
* could be helpful if you need it. Usually you should prefer using the createFullDate function
|
|
12
|
+
* instead.
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseLuxonDateTime(dateTimeInput: DateTime): FullDate;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseLuxonDateTime = exports.toLuxonDateTime = void 0;
|
|
4
|
+
const common_1 = require("@augment-vir/common");
|
|
5
|
+
const luxon_1 = require("luxon");
|
|
6
|
+
/**
|
|
7
|
+
* Converts a FullDate object into a Luxon DateTime library. This is only needed if you need complex
|
|
8
|
+
* operations on dates. It does, however, internally power a lot of the date-vir functionality as it
|
|
9
|
+
* uses the Luxon library for conversions between timezones.
|
|
10
|
+
*/
|
|
11
|
+
function toLuxonDateTime(fullDateInput) {
|
|
12
|
+
const dateTime = luxon_1.DateTime.fromObject((0, common_1.omitObjectKeys)(fullDateInput, ['timezone']), {
|
|
13
|
+
zone: fullDateInput.timezone,
|
|
14
|
+
});
|
|
15
|
+
/** Ignore this edge case in coverage cause idk how to trigger it. */
|
|
16
|
+
/* c8 ignore next 3 */
|
|
17
|
+
if (!dateTime.isValid) {
|
|
18
|
+
throw new Error(dateTime.invalidExplanation ?? undefined);
|
|
19
|
+
}
|
|
20
|
+
return dateTime;
|
|
21
|
+
}
|
|
22
|
+
exports.toLuxonDateTime = toLuxonDateTime;
|
|
23
|
+
/**
|
|
24
|
+
* Convert a Luxon DateTime object into a DateTime object. Used internally inside of date-vir, but
|
|
25
|
+
* could be helpful if you need it. Usually you should prefer using the createFullDate function
|
|
26
|
+
* instead.
|
|
27
|
+
*/
|
|
28
|
+
function parseLuxonDateTime(dateTimeInput) {
|
|
29
|
+
if (!dateTimeInput.isValid) {
|
|
30
|
+
throw new Error(`Invalid input: '${dateTimeInput.toISO()}'`);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
day: dateTimeInput.day,
|
|
34
|
+
month: dateTimeInput.month,
|
|
35
|
+
year: dateTimeInput.year,
|
|
36
|
+
hour: dateTimeInput.hour,
|
|
37
|
+
minute: dateTimeInput.minute,
|
|
38
|
+
second: dateTimeInput.second,
|
|
39
|
+
millisecond: dateTimeInput.millisecond,
|
|
40
|
+
timezone: dateTimeInput.zoneName,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
exports.parseLuxonDateTime = parseLuxonDateTime;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Timezone } from '../timezone/timezone-names';
|
|
2
|
+
import { FullDate } from './full-date-shape';
|
|
3
|
+
/**
|
|
4
|
+
* Parses any strangely formatted dateString using the given formatString and timezone.
|
|
5
|
+
*
|
|
6
|
+
* This is much more flexible than createFullDate but createFullDate should be preferred in
|
|
7
|
+
* situations where it works.
|
|
8
|
+
*
|
|
9
|
+
* The formatString input is passed to Luxon. All format options are listed here:
|
|
10
|
+
* https://moment.github.io/luxon/#/parsing?id=table-of-tokens
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseStrangeString({ dateString, formatString, timezone, }: {
|
|
13
|
+
/** The date string to be parsed. */
|
|
14
|
+
dateString: string;
|
|
15
|
+
/**
|
|
16
|
+
* The format string that should match Luxon's expectations here:
|
|
17
|
+
* https://moment.github.io/luxon/#/parsing?id=table-of-tokens
|
|
18
|
+
*/
|
|
19
|
+
formatString: string;
|
|
20
|
+
/** The timezone that this date/time is meant for / originated from. */
|
|
21
|
+
timezone: Timezone;
|
|
22
|
+
}): FullDate;
|
|
23
|
+
/**
|
|
24
|
+
* Read either an HTMLInputElement's value directly, or the value string retrieved from an
|
|
25
|
+
* HTMLInputElement. Handles both type="date" and type="time" <input> elements.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseInputElementValue(elementOrValue: HTMLInputElement | string | null | undefined, timezone: Timezone): FullDate;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseInputElementValue = exports.parseStrangeString = void 0;
|
|
4
|
+
const common_1 = require("@augment-vir/common");
|
|
5
|
+
const luxon_1 = require("luxon");
|
|
6
|
+
const create_full_date_1 = require("./create-full-date");
|
|
7
|
+
const luxon_date_time_conversion_1 = require("./luxon-date-time-conversion");
|
|
8
|
+
/**
|
|
9
|
+
* Parses any strangely formatted dateString using the given formatString and timezone.
|
|
10
|
+
*
|
|
11
|
+
* This is much more flexible than createFullDate but createFullDate should be preferred in
|
|
12
|
+
* situations where it works.
|
|
13
|
+
*
|
|
14
|
+
* The formatString input is passed to Luxon. All format options are listed here:
|
|
15
|
+
* https://moment.github.io/luxon/#/parsing?id=table-of-tokens
|
|
16
|
+
*/
|
|
17
|
+
function parseStrangeString({ dateString, formatString, timezone, }) {
|
|
18
|
+
try {
|
|
19
|
+
const dateTime = luxon_1.DateTime.fromFormat(dateString, formatString, {
|
|
20
|
+
zone: timezone,
|
|
21
|
+
setZone: true,
|
|
22
|
+
});
|
|
23
|
+
return (0, luxon_date_time_conversion_1.parseLuxonDateTime)(dateTime);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
throw new Error(`Failed to parse string '${dateString}' with format '${formatString}'`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.parseStrangeString = parseStrangeString;
|
|
30
|
+
/**
|
|
31
|
+
* Read either an HTMLInputElement's value directly, or the value string retrieved from an
|
|
32
|
+
* HTMLInputElement. Handles both type="date" and type="time" <input> elements.
|
|
33
|
+
*/
|
|
34
|
+
function parseInputElementValue(elementOrValue, timezone) {
|
|
35
|
+
if (!elementOrValue) {
|
|
36
|
+
throw new Error('Cannot parse an empty element.');
|
|
37
|
+
}
|
|
38
|
+
const value = (0, common_1.isRuntimeTypeOf)(elementOrValue, 'string')
|
|
39
|
+
? elementOrValue
|
|
40
|
+
: elementOrValue.value;
|
|
41
|
+
return (0, create_full_date_1.createFullDate)(value, timezone);
|
|
42
|
+
}
|
|
43
|
+
exports.parseInputElementValue = parseInputElementValue;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { PartialAndUndefined } from '@augment-vir/common';
|
|
2
|
+
import { FullDate } from './full-date-shape';
|
|
3
|
+
import { JustDateString, JustTimeString, JustTimeWithSecondsString, UtcIsoString } from './string-format-types';
|
|
4
|
+
/** Convert a FullDate into a unix timestamp with milliseconds. */
|
|
5
|
+
export declare function toTimestamp(fullDate: FullDate): number;
|
|
6
|
+
/** Convert a FullDate into an ISO string in UTC; always ends in Z. */
|
|
7
|
+
export declare function toIsoString(fullDate: FullDate): UtcIsoString;
|
|
8
|
+
/** Converts the given FullDate into a string in the user's locale, or the given localeOverride. */
|
|
9
|
+
export declare function toLocaleString(fullDate: FullDate, formatOptions?: (Intl.DateTimeFormatOptions & PartialAndUndefined<{
|
|
10
|
+
locale: string;
|
|
11
|
+
}>) | undefined): string;
|
|
12
|
+
/**
|
|
13
|
+
* Provides arbitrary date formatting using Luxon. For full details on the options for the format
|
|
14
|
+
* string input, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens
|
|
15
|
+
*
|
|
16
|
+
* You probably should **prefer toLocaleString** so your users see the format they expect. It
|
|
17
|
+
* already has many formatting options.
|
|
18
|
+
*/
|
|
19
|
+
export declare function toFormattedString(fullDate: FullDate, format: string, localeOverride?: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* The different options for the "type" attribute in an <input> element that require specific
|
|
22
|
+
* formatting relevant to dates.
|
|
23
|
+
*/
|
|
24
|
+
export declare enum HtmlInputElementTypeEnum {
|
|
25
|
+
Date = "date",
|
|
26
|
+
Time = "time"
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Converts a FullDate object into a string that is understood by type="date" or type="time"
|
|
30
|
+
* HTMLInputElement instances. Can optionally include seconds as well for type="time".
|
|
31
|
+
*
|
|
32
|
+
* This does NO timezone operations, the literal stored date and time are simply concatenated into a
|
|
33
|
+
* string. If you wish to convert time zones, first call createFullDate and give it a different time
|
|
34
|
+
* zone.
|
|
35
|
+
*/
|
|
36
|
+
export declare function toHtmlInputString(fullDate: FullDate, inputType: HtmlInputElementTypeEnum.Date): JustDateString;
|
|
37
|
+
export declare function toHtmlInputString(fullDate: FullDate, inputType: HtmlInputElementTypeEnum.Time, includeSeconds?: false | undefined): JustTimeString;
|
|
38
|
+
export declare function toHtmlInputString(fullDate: FullDate, inputType: HtmlInputElementTypeEnum.Time, includeSeconds: true): JustTimeWithSecondsString;
|
|
39
|
+
export declare function toHtmlInputString(fullDate: FullDate, inputType: HtmlInputElementTypeEnum.Time, includeSeconds?: boolean | undefined): JustTimeWithSecondsString | JustTimeString;
|
|
40
|
+
export declare function toHtmlInputString(fullDate: FullDate, inputType: HtmlInputElementTypeEnum, includeSeconds: true): JustDateString | JustTimeWithSecondsString;
|
|
41
|
+
export declare function toHtmlInputString(fullDate: FullDate, inputType: HtmlInputElementTypeEnum, includeSeconds?: false | undefined): JustDateString | JustTimeString;
|
|
42
|
+
export declare function toHtmlInputString(fullDate: FullDate, inputType: HtmlInputElementTypeEnum, includeSeconds?: boolean | undefined): JustDateString | JustTimeWithSecondsString | JustTimeString;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHtmlInputString = exports.HtmlInputElementTypeEnum = exports.toFormattedString = exports.toLocaleString = exports.toIsoString = exports.toTimestamp = void 0;
|
|
4
|
+
const common_1 = require("@augment-vir/common");
|
|
5
|
+
const locales_1 = require("../locales");
|
|
6
|
+
const timezones_1 = require("../timezone/timezones");
|
|
7
|
+
const luxon_date_time_conversion_1 = require("./luxon-date-time-conversion");
|
|
8
|
+
/** Convert a FullDate into a unix timestamp with milliseconds. */
|
|
9
|
+
function toTimestamp(fullDate) {
|
|
10
|
+
return (0, luxon_date_time_conversion_1.toLuxonDateTime)(fullDate).toMillis();
|
|
11
|
+
}
|
|
12
|
+
exports.toTimestamp = toTimestamp;
|
|
13
|
+
/** Convert a FullDate into an ISO string in UTC; always ends in Z. */
|
|
14
|
+
function toIsoString(fullDate) {
|
|
15
|
+
const isoString = (0, luxon_date_time_conversion_1.toLuxonDateTime)(fullDate).setZone(timezones_1.utcTimezone).toISO();
|
|
16
|
+
/** Ignore this edge case in the types and idk how to trigger it. */
|
|
17
|
+
/* c8 ignore next 3 */
|
|
18
|
+
if (!isoString) {
|
|
19
|
+
throw new Error(`Unable to get ISO string for '${JSON.stringify(fullDate)}'`);
|
|
20
|
+
}
|
|
21
|
+
return isoString;
|
|
22
|
+
}
|
|
23
|
+
exports.toIsoString = toIsoString;
|
|
24
|
+
/** Converts the given FullDate into a string in the user's locale, or the given localeOverride. */
|
|
25
|
+
function toLocaleString(fullDate, formatOptions) {
|
|
26
|
+
return (0, luxon_date_time_conversion_1.toLuxonDateTime)(fullDate).toLocaleString({
|
|
27
|
+
...formatOptions,
|
|
28
|
+
}, {
|
|
29
|
+
locale: formatOptions?.locale ?? locales_1.userLocale,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exports.toLocaleString = toLocaleString;
|
|
33
|
+
/**
|
|
34
|
+
* Provides arbitrary date formatting using Luxon. For full details on the options for the format
|
|
35
|
+
* string input, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens
|
|
36
|
+
*
|
|
37
|
+
* You probably should **prefer toLocaleString** so your users see the format they expect. It
|
|
38
|
+
* already has many formatting options.
|
|
39
|
+
*/
|
|
40
|
+
function toFormattedString(fullDate, format, localeOverride = locales_1.userLocale) {
|
|
41
|
+
return (0, luxon_date_time_conversion_1.toLuxonDateTime)(fullDate).toFormat(format, { locale: localeOverride });
|
|
42
|
+
}
|
|
43
|
+
exports.toFormattedString = toFormattedString;
|
|
44
|
+
/**
|
|
45
|
+
* The different options for the "type" attribute in an <input> element that require specific
|
|
46
|
+
* formatting relevant to dates.
|
|
47
|
+
*/
|
|
48
|
+
var HtmlInputElementTypeEnum;
|
|
49
|
+
(function (HtmlInputElementTypeEnum) {
|
|
50
|
+
HtmlInputElementTypeEnum["Date"] = "date";
|
|
51
|
+
HtmlInputElementTypeEnum["Time"] = "time";
|
|
52
|
+
})(HtmlInputElementTypeEnum = exports.HtmlInputElementTypeEnum || (exports.HtmlInputElementTypeEnum = {}));
|
|
53
|
+
function toHtmlInputString(fullDate, inputType, includeSeconds) {
|
|
54
|
+
if (inputType === HtmlInputElementTypeEnum.Date) {
|
|
55
|
+
const dateParts = [
|
|
56
|
+
fullDate.year,
|
|
57
|
+
String(fullDate.month).padStart(2, '0'),
|
|
58
|
+
String(fullDate.day).padStart(2, '0'),
|
|
59
|
+
];
|
|
60
|
+
return dateParts.join('-');
|
|
61
|
+
}
|
|
62
|
+
else if (inputType === HtmlInputElementTypeEnum.Time) {
|
|
63
|
+
const timeParts = [
|
|
64
|
+
String(fullDate.hour).padStart(2, '0'),
|
|
65
|
+
String(fullDate.minute).padStart(2, '0'),
|
|
66
|
+
includeSeconds ? String(fullDate.second).padStart(2, '0') : undefined,
|
|
67
|
+
].filter((entry) => entry != undefined);
|
|
68
|
+
return timeParts.join(':');
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
throw new Error(`Unexpected inputTyped: '${inputType}'. Expected usage of HtmlInputElementTypeEnum or one of ${(0, common_1.getEnumTypedValues)(HtmlInputElementTypeEnum).join(', ')}.`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.toHtmlInputString = toHtmlInputString;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type JustDateString = `${number}-${number}-${number}`;
|
|
2
|
+
export type JustTimeWithSecondsString = `${number}:${number}:${number}`;
|
|
3
|
+
export type JustTimeString = `${number}:${number}`;
|
|
4
|
+
export type UtcIsoString = `${JustDateString}T${JustTimeWithSecondsString}.${number}Z`;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './full-date/create-full-date';
|
|
2
|
+
export * from './full-date/date-like';
|
|
3
|
+
export * from './full-date/format-presets';
|
|
4
|
+
export * from './full-date/full-date-shape';
|
|
5
|
+
export * from './full-date/is-valid-full-date';
|
|
6
|
+
export * from './full-date/luxon-date-time-conversion';
|
|
7
|
+
export * from './full-date/parsing';
|
|
8
|
+
export * from './full-date/primitive-conversions';
|
|
9
|
+
export * from './full-date/string-format-types';
|
|
10
|
+
export * from './locales';
|
|
11
|
+
export * from './timezone/timezone-checks';
|
|
12
|
+
export * from './timezone/timezone-names';
|
|
13
|
+
export * from './timezone/timezones';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./full-date/create-full-date"), exports);
|
|
18
|
+
__exportStar(require("./full-date/date-like"), exports);
|
|
19
|
+
__exportStar(require("./full-date/format-presets"), exports);
|
|
20
|
+
__exportStar(require("./full-date/full-date-shape"), exports);
|
|
21
|
+
__exportStar(require("./full-date/is-valid-full-date"), exports);
|
|
22
|
+
__exportStar(require("./full-date/luxon-date-time-conversion"), exports);
|
|
23
|
+
__exportStar(require("./full-date/parsing"), exports);
|
|
24
|
+
__exportStar(require("./full-date/primitive-conversions"), exports);
|
|
25
|
+
__exportStar(require("./full-date/string-format-types"), exports);
|
|
26
|
+
__exportStar(require("./locales"), exports);
|
|
27
|
+
__exportStar(require("./timezone/timezone-checks"), exports);
|
|
28
|
+
__exportStar(require("./timezone/timezone-names"), exports);
|
|
29
|
+
__exportStar(require("./timezone/timezones"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const userLocale: string;
|
package/dist/locales.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidTimezone = exports.assertValidTimezone = void 0;
|
|
4
|
+
const luxon_1 = require("luxon");
|
|
5
|
+
/**
|
|
6
|
+
* Asserts that the given timezoneName is a valid timezone name.
|
|
7
|
+
*
|
|
8
|
+
* Note that this may actually allow names beyond what is currently in the exact TimezoneName type,
|
|
9
|
+
* because this function uses luxon to check that it is able to generate a date with the given
|
|
10
|
+
* timezone, regardless of whether it's in our typed list or not.
|
|
11
|
+
*/
|
|
12
|
+
function assertValidTimezone(potentialTimezoneName) {
|
|
13
|
+
if (!luxon_1.Info.isValidIANAZone(potentialTimezoneName)) {
|
|
14
|
+
throw new Error(`'${potentialTimezoneName}' is not a valid time zone`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.assertValidTimezone = assertValidTimezone;
|
|
18
|
+
/**
|
|
19
|
+
* Checks that the given timezoneName is a valid timezone name.
|
|
20
|
+
*
|
|
21
|
+
* Note that this may actually allow names beyond what is currently in the exact TimezoneName type,
|
|
22
|
+
* because this function uses luxon to check that it is able to generate a date with the given
|
|
23
|
+
* timezone, regardless of whether it's in our typed list or not.
|
|
24
|
+
*/
|
|
25
|
+
function isValidTimezone(potentialTimezoneName) {
|
|
26
|
+
try {
|
|
27
|
+
assertValidTimezone(potentialTimezoneName);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.isValidTimezone = isValidTimezone;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ArrayElement } from '@augment-vir/common';
|
|
2
|
+
/**
|
|
3
|
+
* This list was generated from Firefox 106.0.2 (which gave me the longest list out of all the
|
|
4
|
+
* browsers I had immediately available to me at the time) with the following code:
|
|
5
|
+
*
|
|
6
|
+
* Intl.supportedValuesOf('timeZone').map(zone => `'${zone}'`).join(',')
|
|
7
|
+
*/
|
|
8
|
+
export declare const allTimezoneNames: readonly ["Africa/Abidjan", "Africa/Accra", "Africa/Addis_Ababa", "Africa/Algiers", "Africa/Asmara", "Africa/Bamako", "Africa/Bangui", "Africa/Banjul", "Africa/Bissau", "Africa/Blantyre", "Africa/Brazzaville", "Africa/Bujumbura", "Africa/Cairo", "Africa/Casablanca", "Africa/Ceuta", "Africa/Conakry", "Africa/Dakar", "Africa/Dar_es_Salaam", "Africa/Djibouti", "Africa/Douala", "Africa/El_Aaiun", "Africa/Freetown", "Africa/Gaborone", "Africa/Harare", "Africa/Johannesburg", "Africa/Juba", "Africa/Kampala", "Africa/Khartoum", "Africa/Kigali", "Africa/Kinshasa", "Africa/Lagos", "Africa/Libreville", "Africa/Lome", "Africa/Luanda", "Africa/Lubumbashi", "Africa/Lusaka", "Africa/Malabo", "Africa/Maputo", "Africa/Maseru", "Africa/Mbabane", "Africa/Mogadishu", "Africa/Monrovia", "Africa/Nairobi", "Africa/Ndjamena", "Africa/Niamey", "Africa/Nouakchott", "Africa/Ouagadougou", "Africa/Porto-Novo", "Africa/Sao_Tome", "Africa/Timbuktu", "Africa/Tripoli", "Africa/Tunis", "Africa/Windhoek", "America/Adak", "America/Anchorage", "America/Anguilla", "America/Antigua", "America/Araguaina", "America/Argentina/Buenos_Aires", "America/Argentina/Catamarca", "America/Argentina/ComodRivadavia", "America/Argentina/Cordoba", "America/Argentina/Jujuy", "America/Argentina/La_Rioja", "America/Argentina/Mendoza", "America/Argentina/Rio_Gallegos", "America/Argentina/Salta", "America/Argentina/San_Juan", "America/Argentina/San_Luis", "America/Argentina/Tucuman", "America/Argentina/Ushuaia", "America/Aruba", "America/Asuncion", "America/Atikokan", "America/Bahia", "America/Bahia_Banderas", "America/Barbados", "America/Belem", "America/Belize", "America/Blanc-Sablon", "America/Boa_Vista", "America/Bogota", "America/Boise", "America/Cambridge_Bay", "America/Campo_Grande", "America/Cancun", "America/Caracas", "America/Cayenne", "America/Cayman", "America/Chicago", "America/Chihuahua", "America/Coral_Harbour", "America/Costa_Rica", "America/Creston", "America/Cuiaba", "America/Curacao", "America/Danmarkshavn", "America/Dawson", "America/Dawson_Creek", "America/Denver", "America/Detroit", "America/Dominica", "America/Edmonton", "America/Eirunepe", "America/El_Salvador", "America/Ensenada", "America/Fort_Nelson", "America/Fortaleza", "America/Glace_Bay", "America/Goose_Bay", "America/Grand_Turk", "America/Grenada", "America/Guadeloupe", "America/Guatemala", "America/Guayaquil", "America/Guyana", "America/Halifax", "America/Havana", "America/Hermosillo", "America/Indiana/Indianapolis", "America/Indiana/Knox", "America/Indiana/Marengo", "America/Indiana/Petersburg", "America/Indiana/Tell_City", "America/Indiana/Vevay", "America/Indiana/Vincennes", "America/Indiana/Winamac", "America/Inuvik", "America/Iqaluit", "America/Jamaica", "America/Juneau", "America/Kentucky/Louisville", "America/Kentucky/Monticello", "America/La_Paz", "America/Lima", "America/Los_Angeles", "America/Maceio", "America/Managua", "America/Manaus", "America/Martinique", "America/Matamoros", "America/Mazatlan", "America/Menominee", "America/Merida", "America/Metlakatla", "America/Mexico_City", "America/Miquelon", "America/Moncton", "America/Monterrey", "America/Montevideo", "America/Montreal", "America/Montserrat", "America/Nassau", "America/New_York", "America/Nipigon", "America/Nome", "America/Noronha", "America/North_Dakota/Beulah", "America/North_Dakota/Center", "America/North_Dakota/New_Salem", "America/Nuuk", "America/Ojinaga", "America/Panama", "America/Pangnirtung", "America/Paramaribo", "America/Phoenix", "America/Port-au-Prince", "America/Port_of_Spain", "America/Porto_Velho", "America/Puerto_Rico", "America/Punta_Arenas", "America/Rainy_River", "America/Rankin_Inlet", "America/Recife", "America/Regina", "America/Resolute", "America/Rio_Branco", "America/Rosario", "America/Santarem", "America/Santiago", "America/Santo_Domingo", "America/Sao_Paulo", "America/Scoresbysund", "America/Sitka", "America/St_Johns", "America/St_Kitts", "America/St_Lucia", "America/St_Thomas", "America/St_Vincent", "America/Swift_Current", "America/Tegucigalpa", "America/Thule", "America/Thunder_Bay", "America/Tijuana", "America/Toronto", "America/Tortola", "America/Vancouver", "America/Whitehorse", "America/Winnipeg", "America/Yakutat", "America/Yellowknife", "Antarctica/Casey", "Antarctica/Davis", "Antarctica/DumontDUrville", "Antarctica/Macquarie", "Antarctica/Mawson", "Antarctica/McMurdo", "Antarctica/Palmer", "Antarctica/Rothera", "Antarctica/Syowa", "Antarctica/Troll", "Antarctica/Vostok", "Asia/Aden", "Asia/Almaty", "Asia/Amman", "Asia/Anadyr", "Asia/Aqtau", "Asia/Aqtobe", "Asia/Ashgabat", "Asia/Atyrau", "Asia/Baghdad", "Asia/Bahrain", "Asia/Baku", "Asia/Bangkok", "Asia/Barnaul", "Asia/Beirut", "Asia/Bishkek", "Asia/Brunei", "Asia/Chita", "Asia/Choibalsan", "Asia/Chongqing", "Asia/Colombo", "Asia/Damascus", "Asia/Dhaka", "Asia/Dili", "Asia/Dubai", "Asia/Dushanbe", "Asia/Famagusta", "Asia/Gaza", "Asia/Harbin", "Asia/Hebron", "Asia/Ho_Chi_Minh", "Asia/Hong_Kong", "Asia/Hovd", "Asia/Irkutsk", "Asia/Jakarta", "Asia/Jayapura", "Asia/Jerusalem", "Asia/Kabul", "Asia/Kamchatka", "Asia/Karachi", "Asia/Kashgar", "Asia/Kathmandu", "Asia/Khandyga", "Asia/Kolkata", "Asia/Krasnoyarsk", "Asia/Kuala_Lumpur", "Asia/Kuching", "Asia/Kuwait", "Asia/Macau", "Asia/Magadan", "Asia/Makassar", "Asia/Manila", "Asia/Muscat", "Asia/Nicosia", "Asia/Novokuznetsk", "Asia/Novosibirsk", "Asia/Omsk", "Asia/Oral", "Asia/Phnom_Penh", "Asia/Pontianak", "Asia/Pyongyang", "Asia/Qatar", "Asia/Qostanay", "Asia/Qyzylorda", "Asia/Riyadh", "Asia/Sakhalin", "Asia/Samarkand", "Asia/Seoul", "Asia/Shanghai", "Asia/Singapore", "Asia/Srednekolymsk", "Asia/Taipei", "Asia/Tashkent", "Asia/Tbilisi", "Asia/Tehran", "Asia/Tel_Aviv", "Asia/Thimphu", "Asia/Tokyo", "Asia/Tomsk", "Asia/Ulaanbaatar", "Asia/Urumqi", "Asia/Ust-Nera", "Asia/Vientiane", "Asia/Vladivostok", "Asia/Yakutsk", "Asia/Yangon", "Asia/Yekaterinburg", "Asia/Yerevan", "Atlantic/Azores", "Atlantic/Bermuda", "Atlantic/Canary", "Atlantic/Cape_Verde", "Atlantic/Faroe", "Atlantic/Jan_Mayen", "Atlantic/Madeira", "Atlantic/Reykjavik", "Atlantic/South_Georgia", "Atlantic/St_Helena", "Atlantic/Stanley", "Australia/Adelaide", "Australia/Brisbane", "Australia/Broken_Hill", "Australia/Currie", "Australia/Darwin", "Australia/Eucla", "Australia/Hobart", "Australia/Lindeman", "Australia/Lord_Howe", "Australia/Melbourne", "Australia/Perth", "Australia/Sydney", "CET", "CST6CDT", "EET", "EST", "EST5EDT", "Etc/GMT+1", "Etc/GMT+10", "Etc/GMT+11", "Etc/GMT+12", "Etc/GMT+2", "Etc/GMT+3", "Etc/GMT+4", "Etc/GMT+5", "Etc/GMT+6", "Etc/GMT+7", "Etc/GMT+8", "Etc/GMT+9", "Etc/GMT-1", "Etc/GMT-10", "Etc/GMT-11", "Etc/GMT-12", "Etc/GMT-13", "Etc/GMT-14", "Etc/GMT-2", "Etc/GMT-3", "Etc/GMT-4", "Etc/GMT-5", "Etc/GMT-6", "Etc/GMT-7", "Etc/GMT-8", "Etc/GMT-9", "Europe/Amsterdam", "Europe/Andorra", "Europe/Astrakhan", "Europe/Athens", "Europe/Belfast", "Europe/Belgrade", "Europe/Berlin", "Europe/Brussels", "Europe/Bucharest", "Europe/Budapest", "Europe/Chisinau", "Europe/Copenhagen", "Europe/Dublin", "Europe/Gibraltar", "Europe/Guernsey", "Europe/Helsinki", "Europe/Isle_of_Man", "Europe/Istanbul", "Europe/Jersey", "Europe/Kaliningrad", "Europe/Kirov", "Europe/Kyiv", "Europe/Lisbon", "Europe/Ljubljana", "Europe/London", "Europe/Luxembourg", "Europe/Madrid", "Europe/Malta", "Europe/Minsk", "Europe/Monaco", "Europe/Moscow", "Europe/Oslo", "Europe/Paris", "Europe/Prague", "Europe/Riga", "Europe/Rome", "Europe/Samara", "Europe/Sarajevo", "Europe/Saratov", "Europe/Simferopol", "Europe/Skopje", "Europe/Sofia", "Europe/Stockholm", "Europe/Tallinn", "Europe/Tirane", "Europe/Tiraspol", "Europe/Ulyanovsk", "Europe/Uzhgorod", "Europe/Vaduz", "Europe/Vienna", "Europe/Vilnius", "Europe/Volgograd", "Europe/Warsaw", "Europe/Zagreb", "Europe/Zaporozhye", "Europe/Zurich", "Factory", "HST", "Indian/Antananarivo", "Indian/Chagos", "Indian/Christmas", "Indian/Cocos", "Indian/Comoro", "Indian/Kerguelen", "Indian/Mahe", "Indian/Maldives", "Indian/Mauritius", "Indian/Mayotte", "Indian/Reunion", "MET", "MST", "MST7MDT", "PST8PDT", "Pacific/Apia", "Pacific/Auckland", "Pacific/Bougainville", "Pacific/Chatham", "Pacific/Chuuk", "Pacific/Easter", "Pacific/Efate", "Pacific/Enderbury", "Pacific/Fakaofo", "Pacific/Fiji", "Pacific/Funafuti", "Pacific/Galapagos", "Pacific/Gambier", "Pacific/Guadalcanal", "Pacific/Guam", "Pacific/Honolulu", "Pacific/Johnston", "Pacific/Kanton", "Pacific/Kiritimati", "Pacific/Kosrae", "Pacific/Kwajalein", "Pacific/Majuro", "Pacific/Marquesas", "Pacific/Midway", "Pacific/Nauru", "Pacific/Niue", "Pacific/Norfolk", "Pacific/Noumea", "Pacific/Pago_Pago", "Pacific/Palau", "Pacific/Pitcairn", "Pacific/Pohnpei", "Pacific/Port_Moresby", "Pacific/Rarotonga", "Pacific/Saipan", "Pacific/Tahiti", "Pacific/Tarawa", "Pacific/Tongatapu", "Pacific/Wake", "Pacific/Wallis", "UTC", "WET"];
|
|
9
|
+
export type Timezone = ArrayElement<typeof allTimezoneNames>;
|