date-vir 8.6.3 → 8.6.4

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.
Files changed (37) hide show
  1. package/README.md +13 -13
  2. package/dist/date-operations/calculate-relative-date.d.ts +1 -2
  3. package/dist/date-operations/combine-dates.d.ts +8 -9
  4. package/dist/date-operations/date-position.d.ts +2 -3
  5. package/dist/date-operations/diff-dates.d.ts +4 -4
  6. package/dist/date-operations/diff-dates.js +4 -4
  7. package/dist/extra-utils/has-date-props.d.ts +2 -3
  8. package/dist/extra-utils/js-date-conversion.d.ts +2 -2
  9. package/dist/extra-utils/js-date-conversion.js +2 -2
  10. package/dist/extra-utils/now.d.ts +4 -4
  11. package/dist/extra-utils/now.js +2 -2
  12. package/dist/extra-utils/override-date.d.ts +4 -5
  13. package/dist/extra-utils/override-date.js +3 -3
  14. package/dist/extra-utils/zero.d.ts +8 -9
  15. package/dist/extra-utils/zero.js +6 -6
  16. package/dist/formatting/simple-strings.d.ts +6 -7
  17. package/dist/formatting/simple-strings.js +1 -1
  18. package/dist/formatting/timestamp.d.ts +6 -6
  19. package/dist/formatting/timestamp.js +6 -6
  20. package/dist/full-date/create-full-date.d.ts +10 -10
  21. package/dist/full-date/create-full-date.js +7 -7
  22. package/dist/full-date/date-like.d.ts +1 -2
  23. package/dist/full-date/full-date-shape.d.ts +9 -10
  24. package/dist/full-date/is-valid-full-date.d.ts +1 -2
  25. package/dist/full-date/luxon-date-time-conversion.d.ts +1 -2
  26. package/dist/full-date/luxon-date-time-conversion.js +2 -7
  27. package/dist/full-date/maybe-create-date.d.ts +1 -2
  28. package/dist/full-date/parsing.d.ts +2 -3
  29. package/dist/full-date/string-parsing.d.ts +1 -2
  30. package/dist/full-date/string-parsing.js +1 -0
  31. package/dist/timezone/timezone-checks.d.ts +2 -15
  32. package/dist/timezone/timezone-checks.js +8 -25
  33. package/dist/timezone/timezone-shape.d.ts +3 -4
  34. package/dist/timezone/timezone-shape.js +2 -2
  35. package/dist/timezone/timezones.d.ts +8 -21
  36. package/dist/timezone/timezones.js +5 -6
  37. package/package.json +2 -2
package/README.md CHANGED
@@ -37,24 +37,24 @@ import {
37
37
  getNowFullDate,
38
38
  parseDateStringWithPattern,
39
39
  parseInputElementValue,
40
- TimezoneName,
40
+ Timezone,
41
41
  } from 'date-vir';
42
42
 
43
43
  /**
44
44
  * Creates a FullDate from a wide range of possible inputs. See TypeScript types for full details on
45
45
  * available inputs.
46
46
  */
47
- createFullDate('2023-06-05', TimezoneName['Europe/Rome']);
47
+ createFullDate('2023-06-05', Timezone['Europe/Rome']);
48
48
 
49
49
  /** Get the current date and time right now in the given timezone. */
50
- getNowFullDate(TimezoneName['America/Argentina/Buenos_Aires']);
50
+ getNowFullDate(Timezone['America/Argentina/Buenos_Aires']);
51
51
 
52
52
  /**
53
53
  * Parsed the value of an <input> element directly from the element itself. This is intended to be
54
54
  * used for type="date" or type="time" <input> elements, but any input element with a valid date or
55
55
  * time string will work.
56
56
  */
57
- parseInputElementValue(document.querySelector('input'), TimezoneName['Asia/Tokyo']);
57
+ parseInputElementValue(document.querySelector('input'), Timezone['Asia/Tokyo']);
58
58
 
59
59
  /**
60
60
  * If you have a really oddly formatted date/time string and createFullDate does not suffice, you
@@ -65,7 +65,7 @@ parseInputElementValue(document.querySelector('input'), TimezoneName['Asia/Tokyo
65
65
  parseDateStringWithPattern({
66
66
  dateString: '870-0-14-19 5 2023 6',
67
67
  formatString: 'S-s-h-m d yyyy M',
68
- timezone: TimezoneName['America/Cancun'],
68
+ timezone: Timezone['America/Cancun'],
69
69
  });
70
70
  ```
71
71
 
@@ -80,14 +80,14 @@ import {
80
80
  createFullDate,
81
81
  formatPresets,
82
82
  FullDatePart,
83
- TimezoneName,
83
+ Timezone,
84
84
  toHtmlInputString,
85
85
  toLocaleString,
86
86
  toTimestamp,
87
87
  toUtcIsoString,
88
88
  } from 'date-vir';
89
89
 
90
- const myFullDate = createFullDate('2023-06-05T14:19:00.870Z', TimezoneName['America/Chicago']);
90
+ const myFullDate = createFullDate('2023-06-05T14:19:00.870Z', Timezone['America/Chicago']);
91
91
 
92
92
  /**
93
93
  * Converts the given FullDate into a UTC unix timestamp with milliseconds. Since the output is a
@@ -123,11 +123,11 @@ toHtmlInputString(myFullDate, FullDatePart.Date); // returns '2023-06-05'
123
123
  <!-- example-link: src/readme-examples/timezones.example.ts -->
124
124
 
125
125
  ```TypeScript
126
- import {TimezoneName, userTimezone, utcTimezone} from 'date-vir';
126
+ import {Timezone, userTimezone, utcTimezone} from 'date-vir';
127
127
 
128
- TimezoneName['Africa/Abidjan'];
129
- TimezoneName['America/Los_Angeles'];
130
- TimezoneName['Etc/GMT+1'];
128
+ Timezone['Africa/Abidjan'];
129
+ Timezone['America/Los_Angeles'];
130
+ Timezone['Etc/GMT+1'];
131
131
 
132
132
  utcTimezone;
133
133
  userTimezone;
@@ -142,9 +142,9 @@ The parsing and timezone conversions in `date-vir` utilize the [`luxon`](https:/
142
142
  <!-- example-link: src/readme-examples/luxon-conversion.example.ts -->
143
143
 
144
144
  ```TypeScript
145
- import {createFullDate, TimezoneName, toLuxonDateTime} from 'date-vir';
145
+ import {createFullDate, Timezone, toLuxonDateTime} from 'date-vir';
146
146
 
147
- const myFullDate = createFullDate('2023-06-05T14:19:00.870Z', TimezoneName['America/Chicago']);
147
+ const myFullDate = createFullDate('2023-06-05T14:19:00.870Z', Timezone['America/Chicago']);
148
148
 
149
149
  toLuxonDateTime(myFullDate);
150
150
  ```
@@ -1,6 +1,5 @@
1
1
  import { type AnyDuration } from '@date-vir/duration';
2
2
  import { type FullDate } from '../full-date/full-date-shape.js';
3
- import { type Timezone } from '../timezone/timezones.js';
4
3
  /**
5
4
  * Calculates a new date starting at the given fullDate and adding the given offsets. Offsets can be
6
5
  * negative to go backwards in time.
@@ -14,4 +13,4 @@ import { type Timezone } from '../timezone/timezones.js';
14
13
  * calculateRelativeDate(getNowInUserTimezone(), {days: 2});
15
14
  * ```
16
15
  */
17
- export declare function calculateRelativeDate<const SpecificTimezone extends Timezone>(fullDate: Readonly<FullDate<SpecificTimezone>>, offset: Readonly<AnyDuration>): FullDate<SpecificTimezone>;
16
+ export declare function calculateRelativeDate<const SpecificTimezone extends string>(fullDate: Readonly<FullDate<SpecificTimezone>>, offset: Readonly<AnyDuration>): FullDate<SpecificTimezone>;
@@ -1,12 +1,11 @@
1
1
  import { type FullDatePart } from '../full-date/full-date-parts.js';
2
2
  import { type DatePart, type FullDate, type TimePart } from '../full-date/full-date-shape.js';
3
- import { type Timezone } from '../timezone/timezones.js';
4
3
  /**
5
4
  * An object containing date and/or time parts or neither. Used for {@link combineDateParts}
6
5
  *
7
6
  * @category Internal
8
7
  */
9
- export type MaybeDateParts<SpecificTimezone extends Timezone> = Partial<{
8
+ export type MaybeDateParts<SpecificTimezone extends string> = Partial<{
10
9
  [FullDatePart.Date]: DatePart<SpecificTimezone> | undefined | Partial<FullDate<SpecificTimezone>>;
11
10
  [FullDatePart.Time]: TimePart<SpecificTimezone> | undefined | Partial<FullDate<SpecificTimezone>>;
12
11
  }>;
@@ -15,8 +14,8 @@ export type MaybeDateParts<SpecificTimezone extends Timezone> = Partial<{
15
14
  *
16
15
  * @category Internal
17
16
  */
18
- export type MaybeDatePart<SpecificTimezone extends Timezone> = FullDate<SpecificTimezone> | Partial<FullDate<SpecificTimezone>> | DatePart<SpecificTimezone> | TimePart<SpecificTimezone> | undefined;
19
- export declare function combineDateParts<const SpecificTimezone extends Timezone>(maybeDateParts: {
17
+ export type MaybeDatePart<SpecificTimezone extends string> = FullDate<SpecificTimezone> | Partial<FullDate<SpecificTimezone>> | DatePart<SpecificTimezone> | TimePart<SpecificTimezone> | undefined;
18
+ export declare function combineDateParts<const SpecificTimezone extends string>(maybeDateParts: {
20
19
  [FullDatePart.Date]: DatePart<SpecificTimezone>;
21
20
  [FullDatePart.Time]: TimePart<SpecificTimezone>;
22
21
  }): FullDate<SpecificTimezone>;
@@ -24,20 +23,20 @@ export declare function combineDateParts(maybeDateParts: {
24
23
  [FullDatePart.Date]?: undefined;
25
24
  [FullDatePart.Time]?: undefined;
26
25
  }): undefined;
27
- export declare function combineDateParts<const SpecificTimezone extends Timezone>(maybeDateParts: {
26
+ export declare function combineDateParts<const SpecificTimezone extends string>(maybeDateParts: {
28
27
  [FullDatePart.Date]: DatePart<SpecificTimezone>;
29
28
  [FullDatePart.Time]?: undefined;
30
29
  }): DatePart<SpecificTimezone>;
31
- export declare function combineDateParts<const SpecificTimezone extends Timezone>(maybeDateParts: {
30
+ export declare function combineDateParts<const SpecificTimezone extends string>(maybeDateParts: {
32
31
  [FullDatePart.Date]: DatePart<SpecificTimezone>;
33
32
  [FullDatePart.Time]?: TimePart<SpecificTimezone> | undefined | Partial<FullDate<SpecificTimezone>>;
34
33
  }): FullDate<SpecificTimezone> | DatePart<SpecificTimezone>;
35
- export declare function combineDateParts<const SpecificTimezone extends Timezone>(maybeDateParts: {
34
+ export declare function combineDateParts<const SpecificTimezone extends string>(maybeDateParts: {
36
35
  [FullDatePart.Date]?: undefined;
37
36
  [FullDatePart.Time]: TimePart<SpecificTimezone>;
38
37
  }): TimePart<SpecificTimezone>;
39
- export declare function combineDateParts<const SpecificTimezone extends Timezone>(maybeDateParts: {
38
+ export declare function combineDateParts<const SpecificTimezone extends string>(maybeDateParts: {
40
39
  [FullDatePart.Date]?: DatePart<SpecificTimezone> | undefined | Partial<FullDate<SpecificTimezone>>;
41
40
  [FullDatePart.Time]: TimePart<SpecificTimezone>;
42
41
  }): FullDate<SpecificTimezone> | TimePart<SpecificTimezone>;
43
- export declare function combineDateParts<const SpecificTimezone extends Timezone>(maybeDateParts: MaybeDateParts<SpecificTimezone>): MaybeDatePart<SpecificTimezone>;
42
+ export declare function combineDateParts<const SpecificTimezone extends string>(maybeDateParts: MaybeDateParts<SpecificTimezone>): MaybeDatePart<SpecificTimezone>;
@@ -1,6 +1,5 @@
1
1
  import { DateUnit } from '@date-vir/duration';
2
2
  import { type FullDate } from '../full-date/full-date-shape.js';
3
- import { type Timezone } from '../timezone/timezones.js';
4
3
  /**
5
4
  * Get the {@link DateUnit} value of a {@link FullDate}.
6
5
  *
@@ -54,7 +53,7 @@ export declare function getDateUnit(date: Readonly<FullDate>, unit: DateUnit): n
54
53
  * ); // outputs {year: 2024, month: 11, day: 1, hour: 0, minute: 0, second: 0, millisecond: 0, timezone: utcTimezone}
55
54
  * ```
56
55
  */
57
- export declare function getStartDate<const SpecificTimezone extends Timezone>(date: Readonly<FullDate<SpecificTimezone>>, unit: DateUnit): FullDate<SpecificTimezone>;
56
+ export declare function getStartDate<const SpecificTimezone extends string>(date: Readonly<FullDate<SpecificTimezone>>, unit: DateUnit): FullDate<SpecificTimezone>;
58
57
  /**
59
58
  * Get the end date of a specific {@link DateUnit} based on a given {@link FullDate}.
60
59
  *
@@ -81,7 +80,7 @@ export declare function getStartDate<const SpecificTimezone extends Timezone>(da
81
80
  * ); // outputs {year: 2024, month: 11, day: 30, hour: 23, minute: 59, second: 59, millisecond: 999, timezone: utcTimezone}
82
81
  * ```
83
82
  */
84
- export declare function getEndDate<const SpecificTimezone extends Timezone>(date: Readonly<FullDate<SpecificTimezone>>, unit: DateUnit): FullDate<SpecificTimezone>;
83
+ export declare function getEndDate<const SpecificTimezone extends string>(date: Readonly<FullDate<SpecificTimezone>>, unit: DateUnit): FullDate<SpecificTimezone>;
85
84
  /**
86
85
  * Shape definition for all valid date position calculations. Used for {@link calculateDatePosition}.
87
86
  *
@@ -13,7 +13,7 @@ import { type FullDate } from '../full-date/full-date-shape.js';
13
13
  * @example
14
14
  *
15
15
  * ```ts
16
- * import {diffDates, DurationUnit, utcTimezone} from 'date-vir';
16
+ * import {diffDates, DurationUnit} from 'date-vir';
17
17
  *
18
18
  * const exampleDate: FullDate = {
19
19
  * year: 2024,
@@ -23,7 +23,7 @@ import { type FullDate } from '../full-date/full-date-shape.js';
23
23
  * minute: 1,
24
24
  * second: 1,
25
25
  * millisecond: 1,
26
- * timezone: utcTimezone,
26
+ * timezone: 'UTC',
27
27
  * };
28
28
  *
29
29
  * // get the diff in days
@@ -59,7 +59,7 @@ units: SelectedUnits, options?: Readonly<RoundOptions>): DurationBySelection<Sel
59
59
  * @example
60
60
  *
61
61
  * ```ts
62
- * import {isDateAfter, type FullDate, utcTimezone} from 'date-vir';
62
+ * import {isDateAfter, type FullDate} from 'date-vir';
63
63
  *
64
64
  * const exampleDate: FullDate = {
65
65
  * year: 2024,
@@ -69,7 +69,7 @@ units: SelectedUnits, options?: Readonly<RoundOptions>): DurationBySelection<Sel
69
69
  * minute: 1,
70
70
  * second: 1,
71
71
  * millisecond: 1,
72
- * timezone: utcTimezone,
72
+ * timezone: 'UTC',
73
73
  * };
74
74
  *
75
75
  * isDateAfter({
@@ -31,7 +31,7 @@ function getHighestPriorityConversionAccuracy(units) {
31
31
  * @example
32
32
  *
33
33
  * ```ts
34
- * import {diffDates, DurationUnit, utcTimezone} from 'date-vir';
34
+ * import {diffDates, DurationUnit} from 'date-vir';
35
35
  *
36
36
  * const exampleDate: FullDate = {
37
37
  * year: 2024,
@@ -41,7 +41,7 @@ function getHighestPriorityConversionAccuracy(units) {
41
41
  * minute: 1,
42
42
  * second: 1,
43
43
  * millisecond: 1,
44
- * timezone: utcTimezone,
44
+ * timezone: 'UTC',
45
45
  * };
46
46
  *
47
47
  * // get the diff in days
@@ -85,7 +85,7 @@ units, options = {}) {
85
85
  * @example
86
86
  *
87
87
  * ```ts
88
- * import {isDateAfter, type FullDate, utcTimezone} from 'date-vir';
88
+ * import {isDateAfter, type FullDate} from 'date-vir';
89
89
  *
90
90
  * const exampleDate: FullDate = {
91
91
  * year: 2024,
@@ -95,7 +95,7 @@ units, options = {}) {
95
95
  * minute: 1,
96
96
  * second: 1,
97
97
  * millisecond: 1,
98
- * timezone: utcTimezone,
98
+ * timezone: 'UTC',
99
99
  * };
100
100
  *
101
101
  * isDateAfter({
@@ -1,6 +1,5 @@
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 Timezone } from '../timezone/timezones.js';
4
3
  /**
5
4
  * Checks that the input has all the requested {@link FullDate} keys.
6
5
  *
@@ -14,7 +13,7 @@ import { type Timezone } from '../timezone/timezones.js';
14
13
  * hasFullDateKeys({year: 2024}, ['day']); // `false`
15
14
  * ```
16
15
  */
17
- export declare function hasFullDateKeys<SpecificTimezone extends Timezone, PartialFullDate extends PartialWithUndefined<FullDate<SpecificTimezone>>,
16
+ export declare function hasFullDateKeys<SpecificTimezone extends string, PartialFullDate extends PartialWithUndefined<FullDate<SpecificTimezone>>,
18
17
  /** A union of strings. */
19
18
  RequiredKeys extends keyof FullDate<SpecificTimezone>>(partialFullDate: PartialWithUndefined<FullDate<SpecificTimezone>>, keys: ReadonlyArray<RequiredKeys>): partialFullDate is SetRequiredAndNotNull<PartialFullDate, RequiredKeys>;
20
19
  /**
@@ -30,6 +29,6 @@ RequiredKeys extends keyof FullDate<SpecificTimezone>>(partialFullDate: PartialW
30
29
  * assertHasFullDateKeys({year: 2024}, ['day']); // fails
31
30
  * ```
32
31
  */
33
- export declare function assertHasFullDateKeys<SpecificTimezone extends Timezone, PartialFullDate extends PartialWithUndefined<FullDate<SpecificTimezone>>,
32
+ export declare function assertHasFullDateKeys<SpecificTimezone extends string, PartialFullDate extends PartialWithUndefined<FullDate<SpecificTimezone>>,
34
33
  /** A union of strings. */
35
34
  RequiredKeys extends keyof FullDate<SpecificTimezone>>(partialFullDate: PartialWithUndefined<FullDate<SpecificTimezone>>, keys: ReadonlyArray<RequiredKeys>): asserts partialFullDate is SetRequiredAndNotNull<PartialFullDate, RequiredKeys>;
@@ -7,7 +7,7 @@ import { type FullDate } from '../full-date/full-date-shape.js';
7
7
  * @example
8
8
  *
9
9
  * ```ts
10
- * import {toJsDate, type FullDate, utcTimezone} from 'date-vir';
10
+ * import {toJsDate, type FullDate} from 'date-vir';
11
11
  *
12
12
  * const exampleDate: Readonly<FullDate> = {
13
13
  * year: 2024,
@@ -17,7 +17,7 @@ import { type FullDate } from '../full-date/full-date-shape.js';
17
17
  * minute: 1,
18
18
  * second: 1,
19
19
  * millisecond: 1,
20
- * timezone: utcTimezone,
20
+ * timezone: 'UTC',
21
21
  * };
22
22
  *
23
23
  * toJsDate(exampleDate);
@@ -8,7 +8,7 @@ import { userTimezone } from '../timezone/timezones.js';
8
8
  * @example
9
9
  *
10
10
  * ```ts
11
- * import {toJsDate, type FullDate, utcTimezone} from 'date-vir';
11
+ * import {toJsDate, type FullDate} from 'date-vir';
12
12
  *
13
13
  * const exampleDate: Readonly<FullDate> = {
14
14
  * year: 2024,
@@ -18,7 +18,7 @@ import { userTimezone } from '../timezone/timezones.js';
18
18
  * minute: 1,
19
19
  * second: 1,
20
20
  * millisecond: 1,
21
- * timezone: utcTimezone,
21
+ * timezone: 'UTC',
22
22
  * };
23
23
  *
24
24
  * toJsDate(exampleDate);
@@ -1,6 +1,6 @@
1
1
  import { type UtcIsoString } from '../formatting/string-format-types.js';
2
2
  import { type FullDate } from '../full-date/full-date-shape.js';
3
- import { type Timezone, type UtcTimezone } from '../timezone/timezones.js';
3
+ import { type UtcTimezone } from '../timezone/timezones.js';
4
4
  /**
5
5
  * Get the time right now as a UTC ISO.
6
6
  *
@@ -47,10 +47,10 @@ export declare function getNowInUtcTimezone(): FullDate<UtcTimezone>;
47
47
  * @example
48
48
  *
49
49
  * ```ts
50
- * import {getNowFullDate, TimezoneName, utcTimezone} from 'date-vir';
50
+ * import {getNowFullDate, utcTimezone, timezones} from 'date-vir';
51
51
  *
52
52
  * getNowFullDate(utcTimezone);
53
- * getNowFullDate(TimezoneName['Australia/Brisbane']);
53
+ * getNowFullDate(timezones['Australia/Brisbane']);
54
54
  * ```
55
55
  */
56
- export declare function getNowFullDate<const SpecificTimezone extends Timezone>(timezone: SpecificTimezone): FullDate<SpecificTimezone>;
56
+ export declare function getNowFullDate<const SpecificTimezone extends string>(timezone: SpecificTimezone): FullDate<SpecificTimezone>;
@@ -57,10 +57,10 @@ export function getNowInUtcTimezone() {
57
57
  * @example
58
58
  *
59
59
  * ```ts
60
- * import {getNowFullDate, TimezoneName, utcTimezone} from 'date-vir';
60
+ * import {getNowFullDate, utcTimezone, timezones} from 'date-vir';
61
61
  *
62
62
  * getNowFullDate(utcTimezone);
63
- * getNowFullDate(TimezoneName['Australia/Brisbane']);
63
+ * getNowFullDate(timezones['Australia/Brisbane']);
64
64
  * ```
65
65
  */
66
66
  export function getNowFullDate(timezone) {
@@ -1,5 +1,4 @@
1
1
  import { type FullDate } from '../full-date/full-date-shape.js';
2
- import { type Timezone } from '../timezone/timezones.js';
3
2
  /**
4
3
  * Override the initial provided FullDate with all subsequent FullDate parts.
5
4
  *
@@ -7,7 +6,7 @@ import { type Timezone } from '../timezone/timezones.js';
7
6
  * @example
8
7
  *
9
8
  * ```ts
10
- * import {overrideDateParts, type FullDate, utcTimezone} from 'date-vir';
9
+ * import {overrideDateParts, type FullDate} from 'date-vir';
11
10
  *
12
11
  * const exampleDate: Readonly<FullDate> = {
13
12
  * year: 2024,
@@ -17,11 +16,11 @@ import { type Timezone } from '../timezone/timezones.js';
17
16
  * minute: 1,
18
17
  * second: 1,
19
18
  * millisecond: 1,
20
- * timezone: utcTimezone,
19
+ * timezone: 'UTC',
21
20
  * };
22
21
  *
23
22
  * overrideDateParts(exampleDate, {day: 20}, {second: 10});
24
- * // `{year: 2024, month: 1, day: 20, hour: 1, minute: 1, second: 10, millisecond: 1, timezone: utcTimezone}`
23
+ * // `{year: 2024, month: 1, day: 20, hour: 1, minute: 1, second: 10, millisecond: 1, timezone: 'UTC'}`
25
24
  * ```
26
25
  */
27
- export declare function overrideDateParts<const SpecificTimezone extends Timezone>(date: FullDate<SpecificTimezone>, ...overrides: Partial<FullDate<SpecificTimezone>>[]): FullDate<SpecificTimezone>;
26
+ export declare function overrideDateParts<const SpecificTimezone extends string>(date: FullDate<SpecificTimezone>, ...overrides: Partial<FullDate<SpecificTimezone>>[]): FullDate<SpecificTimezone>;
@@ -5,7 +5,7 @@
5
5
  * @example
6
6
  *
7
7
  * ```ts
8
- * import {overrideDateParts, type FullDate, utcTimezone} from 'date-vir';
8
+ * import {overrideDateParts, type FullDate} from 'date-vir';
9
9
  *
10
10
  * const exampleDate: Readonly<FullDate> = {
11
11
  * year: 2024,
@@ -15,11 +15,11 @@
15
15
  * minute: 1,
16
16
  * second: 1,
17
17
  * millisecond: 1,
18
- * timezone: utcTimezone,
18
+ * timezone: 'UTC',
19
19
  * };
20
20
  *
21
21
  * overrideDateParts(exampleDate, {day: 20}, {second: 10});
22
- * // `{year: 2024, month: 1, day: 20, hour: 1, minute: 1, second: 10, millisecond: 1, timezone: utcTimezone}`
22
+ * // `{year: 2024, month: 1, day: 20, hour: 1, minute: 1, second: 10, millisecond: 1, timezone: 'UTC'}`
23
23
  * ```
24
24
  */
25
25
  export function overrideDateParts(date, ...overrides) {
@@ -1,6 +1,5 @@
1
1
  import { TimeKey } from '../full-date/full-date-parts.js';
2
2
  import { type FullDate } from '../full-date/full-date-shape.js';
3
- import { type Timezone } from '../timezone/timezones.js';
4
3
  /**
5
4
  * A {@link FullDate} instance that has the lowest, valid, non-negative, value for each property.
6
5
  *
@@ -51,7 +50,7 @@ export declare const zeroTime: Pick<{
51
50
  * @example
52
51
  *
53
52
  * ```ts
54
- * import {clearTime, type FullDate, utcTimezone} from 'date-vir';
53
+ * import {clearTime, type FullDate} from 'date-vir';
55
54
  *
56
55
  * const exampleDate: Readonly<FullDate> = {
57
56
  * year: 2024,
@@ -61,14 +60,14 @@ export declare const zeroTime: Pick<{
61
60
  * minute: 1,
62
61
  * second: 1,
63
62
  * millisecond: 1,
64
- * timezone: utcTimezone,
63
+ * timezone: 'UTC',
65
64
  * };
66
65
  *
67
66
  * clearTime(exampleDate);
68
- * // `{year: 2024, month: 1, day: 5, hour: 0, minute: 0, second: 0, millisecond: 0, timezone: utcTimezone}`
67
+ * // `{year: 2024, month: 1, day: 5, hour: 0, minute: 0, second: 0, millisecond: 0, timezone: 'UTC'}`
69
68
  * ```
70
69
  */
71
- export declare function clearTime<const SpecificTimezone extends Timezone>(inputFullDate: Readonly<FullDate<SpecificTimezone>>): FullDate<SpecificTimezone>;
70
+ export declare function clearTime<const SpecificTimezone extends string>(inputFullDate: Readonly<FullDate<SpecificTimezone>>): FullDate<SpecificTimezone>;
72
71
  /**
73
72
  * Clear all the selected parts of {@link FullDate} by setting them each to their lowest, valid
74
73
  * value. See {@link zeroDate} for the lowest valid values for each property.
@@ -77,7 +76,7 @@ export declare function clearTime<const SpecificTimezone extends Timezone>(input
77
76
  * @example
78
77
  *
79
78
  * ```ts
80
- * import {clearTime, type FullDate, utcTimezone} from 'date-vir';
79
+ * import {clearTime, type FullDate} from 'date-vir';
81
80
  *
82
81
  * const exampleDate: Readonly<FullDate> = {
83
82
  * year: 2024,
@@ -87,17 +86,17 @@ export declare function clearTime<const SpecificTimezone extends Timezone>(input
87
86
  * minute: 1,
88
87
  * second: 1,
89
88
  * millisecond: 1,
90
- * timezone: utcTimezone,
89
+ * timezone: 'UTC',
91
90
  * };
92
91
  *
93
92
  * clearParts(exampleDate, [
94
93
  * 'year',
95
94
  * 'day',
96
95
  * ]);
97
- * // `{year: 0, month: 1, day: 1, hour: 1, minute: 1, second: 1, millisecond: 1, timezone: utcTimezone}`
96
+ * // `{year: 0, month: 1, day: 1, hour: 1, minute: 1, second: 1, millisecond: 1, timezone: 'UTC'}`
98
97
  * ```
99
98
  */
100
- export declare function clearParts<const SpecificTimezone extends Timezone>(inputFullDate: Readonly<FullDate<SpecificTimezone>>, parts: ReadonlyArray<Exclude<keyof FullDate, 'timezone'>>): {
99
+ export declare function clearParts<const SpecificTimezone extends string>(inputFullDate: Readonly<FullDate<SpecificTimezone>>, parts: ReadonlyArray<Exclude<keyof FullDate, 'timezone'>>): {
101
100
  year: number;
102
101
  month: import("@date-vir/duration").MonthNumber;
103
102
  day: import("@date-vir/duration").DayOfMonth;
@@ -35,7 +35,7 @@ export const zeroTime = pickObjectKeys(zeroDate, getEnumValues(TimeKey));
35
35
  * @example
36
36
  *
37
37
  * ```ts
38
- * import {clearTime, type FullDate, utcTimezone} from 'date-vir';
38
+ * import {clearTime, type FullDate} from 'date-vir';
39
39
  *
40
40
  * const exampleDate: Readonly<FullDate> = {
41
41
  * year: 2024,
@@ -45,11 +45,11 @@ export const zeroTime = pickObjectKeys(zeroDate, getEnumValues(TimeKey));
45
45
  * minute: 1,
46
46
  * second: 1,
47
47
  * millisecond: 1,
48
- * timezone: utcTimezone,
48
+ * timezone: 'UTC',
49
49
  * };
50
50
  *
51
51
  * clearTime(exampleDate);
52
- * // `{year: 2024, month: 1, day: 5, hour: 0, minute: 0, second: 0, millisecond: 0, timezone: utcTimezone}`
52
+ * // `{year: 2024, month: 1, day: 5, hour: 0, minute: 0, second: 0, millisecond: 0, timezone: 'UTC'}`
53
53
  * ```
54
54
  */
55
55
  export function clearTime(inputFullDate) {
@@ -63,7 +63,7 @@ export function clearTime(inputFullDate) {
63
63
  * @example
64
64
  *
65
65
  * ```ts
66
- * import {clearTime, type FullDate, utcTimezone} from 'date-vir';
66
+ * import {clearTime, type FullDate} from 'date-vir';
67
67
  *
68
68
  * const exampleDate: Readonly<FullDate> = {
69
69
  * year: 2024,
@@ -73,14 +73,14 @@ export function clearTime(inputFullDate) {
73
73
  * minute: 1,
74
74
  * second: 1,
75
75
  * millisecond: 1,
76
- * timezone: utcTimezone,
76
+ * timezone: 'UTC',
77
77
  * };
78
78
  *
79
79
  * clearParts(exampleDate, [
80
80
  * 'year',
81
81
  * 'day',
82
82
  * ]);
83
- * // `{year: 0, month: 1, day: 1, hour: 1, minute: 1, second: 1, millisecond: 1, timezone: utcTimezone}`
83
+ * // `{year: 0, month: 1, day: 1, hour: 1, minute: 1, second: 1, millisecond: 1, timezone: 'UTC'}`
84
84
  * ```
85
85
  */
86
86
  export function clearParts(inputFullDate, parts) {
@@ -1,6 +1,5 @@
1
1
  import { type SetOptionalAndNullable } from '@augment-vir/common';
2
2
  import { type FullDate } from '../full-date/full-date-shape.js';
3
- import { type Timezone } from '../timezone/timezones.js';
4
3
  import { type JustDateString, type JustTimeString, type JustTimeWithSecondsString } from './string-format-types.js';
5
4
  /**
6
5
  * Create a string based on just the date parts of a FullDate.
@@ -58,7 +57,7 @@ export type FullDateForParts = SetOptionalAndNullable<FullDate, 'millisecond'>;
58
57
  * result = {
59
58
  * date: '2024-04-24',
60
59
  * time: '06:04:09',
61
- * timezone: utcTimezone,
60
+ * timezone: 'UTC',
62
61
  * };
63
62
  * ```
64
63
  */
@@ -67,7 +66,7 @@ export declare function toDatePartStrings(fullDate: FullDateForParts, options: {
67
66
  }): {
68
67
  date: JustDateString;
69
68
  time: JustTimeWithSecondsString;
70
- timezone: Timezone;
69
+ timezone: string;
71
70
  };
72
71
  /**
73
72
  * Splits a FullDate up into multiple formatted string representations.
@@ -99,7 +98,7 @@ export declare function toDatePartStrings(fullDate: FullDateForParts, options: {
99
98
  * result = {
100
99
  * date: '2024-04-24',
101
100
  * time: '06:04:09',
102
- * timezone: utcTimezone,
101
+ * timezone: 'UTC',
103
102
  * };
104
103
  * ```
105
104
  */
@@ -108,7 +107,7 @@ export declare function toDatePartStrings(fullDate: SetOptionalAndNullable<FullD
108
107
  }): {
109
108
  date: JustDateString;
110
109
  time: JustTimeString;
111
- timezone: Timezone;
110
+ timezone: string;
112
111
  };
113
112
  /**
114
113
  * Splits a FullDate up into multiple formatted string representations.
@@ -140,7 +139,7 @@ export declare function toDatePartStrings(fullDate: SetOptionalAndNullable<FullD
140
139
  * result = {
141
140
  * date: '2024-04-24',
142
141
  * time: '06:04:09',
143
- * timezone: utcTimezone,
142
+ * timezone: 'UTC',
144
143
  * };
145
144
  * ```
146
145
  */
@@ -149,7 +148,7 @@ export declare function toDatePartStrings(fullDate: FullDateForParts, options: {
149
148
  }): {
150
149
  date: JustDateString;
151
150
  time: JustTimeWithSecondsString | JustTimeString;
152
- timezone: Timezone;
151
+ timezone: string;
153
152
  };
154
153
  /**
155
154
  * Converts a date into a simple, unambiguous date string.
@@ -67,7 +67,7 @@ export function toSimpleTimePartString(fullDate, includeSeconds) {
67
67
  * result = {
68
68
  * date: '2024-04-24',
69
69
  * time: '06:04:09',
70
- * timezone: utcTimezone,
70
+ * timezone: 'UTC',
71
71
  * };
72
72
  * ```
73
73
  */
@@ -8,7 +8,7 @@ import { type HttpDateString, type UtcIsoString } from './string-format-types.js
8
8
  * @example
9
9
  *
10
10
  * ```ts
11
- * import {toTimestamp, utcTimezone} from 'date-vir';
11
+ * import {toTimestamp} from 'date-vir';
12
12
  *
13
13
  * const exampleDate: FullDate = {
14
14
  * year: 2024,
@@ -18,7 +18,7 @@ import { type HttpDateString, type UtcIsoString } from './string-format-types.js
18
18
  * minute: 1,
19
19
  * second: 1,
20
20
  * millisecond: 1,
21
- * timezone: utcTimezone,
21
+ * timezone: 'UTC',
22
22
  * };
23
23
  *
24
24
  * toTimestamp(exampleDate); // `1704416461001`
@@ -37,7 +37,7 @@ export declare function toTimestamp(fullDate: FullDate): number;
37
37
  * @example
38
38
  *
39
39
  * ```ts
40
- * import {toUtcIsoString, utcTimezone} from 'date-vir';
40
+ * import {toUtcIsoString} from 'date-vir';
41
41
  *
42
42
  * const exampleDate: FullDate = {
43
43
  * year: 2024,
@@ -47,7 +47,7 @@ export declare function toTimestamp(fullDate: FullDate): number;
47
47
  * minute: 1,
48
48
  * second: 1,
49
49
  * millisecond: 1,
50
- * timezone: utcTimezone,
50
+ * timezone: 'UTC',
51
51
  * };
52
52
  *
53
53
  * toUtcIsoString(exampleDate); // `'2024-01-05T01:01:01.001Z'`
@@ -93,7 +93,7 @@ dateLike: Readonly<DateLike>): UtcIsoString;
93
93
  * @example
94
94
  *
95
95
  * ```ts
96
- * import {toHttpDateString, utcTimezone} from 'date-vir';
96
+ * import {toHttpDateString} from 'date-vir';
97
97
  *
98
98
  * const exampleDate: FullDate = {
99
99
  * year: 2024,
@@ -103,7 +103,7 @@ dateLike: Readonly<DateLike>): UtcIsoString;
103
103
  * minute: 1,
104
104
  * second: 1,
105
105
  * millisecond: 1,
106
- * timezone: utcTimezone,
106
+ * timezone: 'UTC',
107
107
  * };
108
108
  *
109
109
  * toHttpDateString(exampleDate); // `'Fri, 05 Jan 2024 01:01:01 GMT'`
@@ -8,7 +8,7 @@ import { utcTimezone } from '../timezone/timezones.js';
8
8
  * @example
9
9
  *
10
10
  * ```ts
11
- * import {toTimestamp, utcTimezone} from 'date-vir';
11
+ * import {toTimestamp} from 'date-vir';
12
12
  *
13
13
  * const exampleDate: FullDate = {
14
14
  * year: 2024,
@@ -18,7 +18,7 @@ import { utcTimezone } from '../timezone/timezones.js';
18
18
  * minute: 1,
19
19
  * second: 1,
20
20
  * millisecond: 1,
21
- * timezone: utcTimezone,
21
+ * timezone: 'UTC',
22
22
  * };
23
23
  *
24
24
  * toTimestamp(exampleDate); // `1704416461001`
@@ -39,7 +39,7 @@ export function toTimestamp(fullDate) {
39
39
  * @example
40
40
  *
41
41
  * ```ts
42
- * import {toUtcIsoString, utcTimezone} from 'date-vir';
42
+ * import {toUtcIsoString} from 'date-vir';
43
43
  *
44
44
  * const exampleDate: FullDate = {
45
45
  * year: 2024,
@@ -49,7 +49,7 @@ export function toTimestamp(fullDate) {
49
49
  * minute: 1,
50
50
  * second: 1,
51
51
  * millisecond: 1,
52
- * timezone: utcTimezone,
52
+ * timezone: 'UTC',
53
53
  * };
54
54
  *
55
55
  * toUtcIsoString(exampleDate); // `'2024-01-05T01:01:01.001Z'`
@@ -105,7 +105,7 @@ dateLike) {
105
105
  * @example
106
106
  *
107
107
  * ```ts
108
- * import {toHttpDateString, utcTimezone} from 'date-vir';
108
+ * import {toHttpDateString} from 'date-vir';
109
109
  *
110
110
  * const exampleDate: FullDate = {
111
111
  * year: 2024,
@@ -115,7 +115,7 @@ dateLike) {
115
115
  * minute: 1,
116
116
  * second: 1,
117
117
  * millisecond: 1,
118
- * timezone: utcTimezone,
118
+ * timezone: 'UTC',
119
119
  * };
120
120
  *
121
121
  * toHttpDateString(exampleDate); // `'Fri, 05 Jan 2024 01:01:01 GMT'`
@@ -1,4 +1,4 @@
1
- import { type Timezone, type UtcTimezone } from '../timezone/timezones.js';
1
+ import { type UtcTimezone } from '../timezone/timezones.js';
2
2
  import { type DateLike } from './date-like.js';
3
3
  import { type FullDate } from './full-date-shape.js';
4
4
  /**
@@ -45,16 +45,16 @@ export declare function createUtcFullDate(dateLike: Readonly<DateLike>): FullDat
45
45
  * @example
46
46
  *
47
47
  * ```ts
48
- * import {createFullDate, TimezoneName, utcTimezone} from 'date-vir';
48
+ * import {createFullDate, timezones, utcTimezone} from 'date-vir';
49
49
  *
50
50
  * createFullDate('June 1, 2024', utcTimezone);
51
- * createFullDate(new Date(), TimezoneName['Australia/Brisbane']);
52
- * createFullDate(112300120, TimezoneName['Etc/GMT-11']);
51
+ * createFullDate(new Date(), timezones['Australia/Brisbane']);
52
+ * createFullDate(112300120, timezones['Etc/GMT-11']);
53
53
  * ```
54
54
  *
55
55
  * @throws Error: if a valid date cannot be created.
56
56
  */
57
- export declare function createFullDate<const SpecificTimezone extends Timezone>(
57
+ export declare function createFullDate<const SpecificTimezone extends string>(
58
58
  /** The original date representation to be converted into a FullDate. */
59
59
  dateLike: Readonly<DateLike>,
60
60
  /** The timezone that this date/time is meant for / originated from. */
@@ -67,7 +67,7 @@ timezone: SpecificTimezone): FullDate<SpecificTimezone>;
67
67
  * @example
68
68
  *
69
69
  * ```ts
70
- * import {toNewTimezone, TimezoneName, utcTimezone} from 'date-vir';
70
+ * import {toNewTimezone} from 'date-vir';
71
71
  *
72
72
  * const exampleDate: FullDate = {
73
73
  * year: 2024,
@@ -77,10 +77,10 @@ timezone: SpecificTimezone): FullDate<SpecificTimezone>;
77
77
  * minute: 1,
78
78
  * second: 1,
79
79
  * millisecond: 1,
80
- * timezone: utcTimezone,
80
+ * timezone: 'UTC',
81
81
  * };
82
82
  *
83
- * let result = toNewTimezone(exampleDate, TimezoneName['Australia/Brisbane']);
83
+ * let result = toNewTimezone(exampleDate, timezones['Australia/Brisbane']);
84
84
  * // output:
85
85
  * result = {
86
86
  * year: 2024,
@@ -90,8 +90,8 @@ timezone: SpecificTimezone): FullDate<SpecificTimezone>;
90
90
  * minute: 1,
91
91
  * second: 1,
92
92
  * millisecond: 1,
93
- * timezone: TimezoneName['Australia/Brisbane'],
93
+ * timezone: timezones['Australia/Brisbane'],
94
94
  * };
95
95
  * ```
96
96
  */
97
- export declare function toNewTimezone<const SpecificTimezone extends Timezone>(fullDate: Readonly<FullDate>, timezone: SpecificTimezone): FullDate<SpecificTimezone>;
97
+ export declare function toNewTimezone<const SpecificTimezone extends string>(fullDate: Readonly<FullDate>, timezone: SpecificTimezone): FullDate<SpecificTimezone>;
@@ -53,11 +53,11 @@ export function createUtcFullDate(dateLike) {
53
53
  * @example
54
54
  *
55
55
  * ```ts
56
- * import {createFullDate, TimezoneName, utcTimezone} from 'date-vir';
56
+ * import {createFullDate, timezones, utcTimezone} from 'date-vir';
57
57
  *
58
58
  * createFullDate('June 1, 2024', utcTimezone);
59
- * createFullDate(new Date(), TimezoneName['Australia/Brisbane']);
60
- * createFullDate(112300120, TimezoneName['Etc/GMT-11']);
59
+ * createFullDate(new Date(), timezones['Australia/Brisbane']);
60
+ * createFullDate(112300120, timezones['Etc/GMT-11']);
61
61
  * ```
62
62
  *
63
63
  * @throws Error: if a valid date cannot be created.
@@ -81,7 +81,7 @@ timezone) {
81
81
  * @example
82
82
  *
83
83
  * ```ts
84
- * import {toNewTimezone, TimezoneName, utcTimezone} from 'date-vir';
84
+ * import {toNewTimezone} from 'date-vir';
85
85
  *
86
86
  * const exampleDate: FullDate = {
87
87
  * year: 2024,
@@ -91,10 +91,10 @@ timezone) {
91
91
  * minute: 1,
92
92
  * second: 1,
93
93
  * millisecond: 1,
94
- * timezone: utcTimezone,
94
+ * timezone: 'UTC',
95
95
  * };
96
96
  *
97
- * let result = toNewTimezone(exampleDate, TimezoneName['Australia/Brisbane']);
97
+ * let result = toNewTimezone(exampleDate, timezones['Australia/Brisbane']);
98
98
  * // output:
99
99
  * result = {
100
100
  * year: 2024,
@@ -104,7 +104,7 @@ timezone) {
104
104
  * minute: 1,
105
105
  * second: 1,
106
106
  * millisecond: 1,
107
- * timezone: TimezoneName['Australia/Brisbane'],
107
+ * timezone: timezones['Australia/Brisbane'],
108
108
  * };
109
109
  * ```
110
110
  */
@@ -1,9 +1,8 @@
1
1
  import { type DateTime } from 'luxon';
2
- import { type Timezone } from '../timezone/timezones.js';
3
2
  import { type FullDate } from './full-date-shape.js';
4
3
  /**
5
4
  * Types that can be converted into {@link FullDate} instances.
6
5
  *
7
6
  * @category Internal
8
7
  */
9
- export type DateLike<SpecificTimezone extends Timezone = Timezone> = string | Date | number | DateTime | FullDate<SpecificTimezone>;
8
+ export type DateLike<SpecificTimezone extends string = string> = string | Date | number | DateTime | FullDate<SpecificTimezone>;
@@ -1,7 +1,6 @@
1
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
3
  import { type Simplify } from 'type-fest';
4
- import { type Timezone } from '../timezone/timezones.js';
5
4
  /**
6
5
  * Time part of {@link FullDate} represented in a shape definition.
7
6
  *
@@ -17,14 +16,14 @@ export declare const timePartShape: import("object-shape-tester").Shape<{
17
16
  /** Millisecond of the second: 0-999 */
18
17
  millisecond: import("object-shape-tester").Shape<import("@sinclair/typebox").TUnsafe<number>>;
19
18
  /** The timezone that this date/time is meant for / originated from. */
20
- timezone: import("object-shape-tester").Shape<import("@sinclair/typebox").TUnsafe<Timezone>>;
19
+ timezone: import("object-shape-tester").Shape<import("@sinclair/typebox").TUnsafe<string>>;
21
20
  }>;
22
21
  /**
23
22
  * Time part of a {@link FullDate}.
24
23
  *
25
24
  * @category Internal
26
25
  */
27
- export type TimePart<SpecificTimezone extends Timezone = Timezone> = SetRequired<Partial<FullDate<SpecificTimezone>>, keyof (typeof timePartShape)['runtimeType']>;
26
+ export type TimePart<SpecificTimezone extends string = string> = SetRequired<Partial<FullDate<SpecificTimezone>>, keyof (typeof timePartShape)['runtimeType']>;
28
27
  /**
29
28
  * Date part of {@link FullDate} represented in a shape definition.
30
29
  *
@@ -42,14 +41,14 @@ export declare const datePartShape: import("object-shape-tester").Shape<{
42
41
  /** A day of the month: 1-31 depending on the month */
43
42
  day: import("object-shape-tester").Shape<import("@sinclair/typebox").TUnsafe<DayOfMonth>>;
44
43
  /** The timezone that this date/time is meant for / originated from. */
45
- timezone: import("object-shape-tester").Shape<import("@sinclair/typebox").TUnsafe<Timezone>>;
44
+ timezone: import("object-shape-tester").Shape<import("@sinclair/typebox").TUnsafe<string>>;
46
45
  }>;
47
46
  /**
48
47
  * Date part of {@link FullDate}.
49
48
  *
50
49
  * @category Internal
51
50
  */
52
- export type DatePart<SpecificTimezone extends Timezone = Timezone> = SetRequired<Partial<FullDate<SpecificTimezone>>, keyof (typeof datePartShape)['runtimeType']>;
51
+ export type DatePart<SpecificTimezone extends string = string> = SetRequired<Partial<FullDate<SpecificTimezone>>, keyof (typeof datePartShape)['runtimeType']>;
53
52
  /**
54
53
  * The complete {@link FullDate} represented in a shape definition.
55
54
  *
@@ -60,12 +59,12 @@ export declare const fullDateShape: import("object-shape-tester").Shape<import("
60
59
  minute: Minute;
61
60
  second: Minute;
62
61
  millisecond: number;
63
- timezone: Timezone;
62
+ timezone: string;
64
63
  } & {
65
64
  year: number;
66
65
  month: MonthNumber;
67
66
  day: DayOfMonth;
68
- timezone: Timezone;
67
+ timezone: string;
69
68
  }>>>;
70
69
  /**
71
70
  * A serializable object that completely specifies how any given date should be represented,
@@ -76,7 +75,7 @@ export declare const fullDateShape: import("object-shape-tester").Shape<import("
76
75
  * @example
77
76
  *
78
77
  * ```ts
79
- * import {FullDate, TimezoneName} from 'date-vir';
78
+ * import {FullDate, timezones} from 'date-vir';
80
79
  *
81
80
  * const myDate: FullDate = {
82
81
  * year: 2024,
@@ -88,11 +87,11 @@ export declare const fullDateShape: import("object-shape-tester").Shape<import("
88
87
  * second: 12,
89
88
  *
90
89
  * milliseconds: 94,
91
- * timezone: TimezoneName['Australia/Brisbane'],
90
+ * timezone: timezones['Australia/Brisbane'],
92
91
  * };
93
92
  * ```
94
93
  */
95
- export type FullDate<SpecificTimezone extends Timezone = Timezone> = Simplify<Overwrite<(typeof fullDateShape)['runtimeType'], {
94
+ export type FullDate<SpecificTimezone extends string = string> = Simplify<Overwrite<(typeof fullDateShape)['runtimeType'], {
96
95
  second: Second;
97
96
  timezone: SpecificTimezone;
98
97
  }>>;
@@ -1,4 +1,3 @@
1
- import { type Timezone } from '../timezone/timezones.js';
2
1
  import { type FullDate } from './full-date-shape.js';
3
2
  /**
4
3
  * Asserts that the input is a valid {@link FullDate}.
@@ -18,4 +17,4 @@ export declare function isValidFullDate(input: unknown): input is FullDate;
18
17
  *
19
18
  * @category Assertion
20
19
  */
21
- export declare function hasTimezone<const SpecificTimezone extends Timezone>(input: FullDate, timezone: SpecificTimezone): input is FullDate<SpecificTimezone>;
20
+ export declare function hasTimezone<const SpecificTimezone extends string>(input: FullDate, timezone: SpecificTimezone): input is FullDate<SpecificTimezone>;
@@ -1,5 +1,4 @@
1
1
  import { DateTime } from 'luxon';
2
- import { type Timezone } from '../timezone/timezones.js';
3
2
  import { type FullDate } from './full-date-shape.js';
4
3
  /**
5
4
  * Converts a {@link FullDate} object into a Luxon DateTime library. This is only needed if you need
@@ -16,4 +15,4 @@ export declare function toLuxonDateTime(fullDateInput: Readonly<FullDate>): Date
16
15
  *
17
16
  * @category Internal
18
17
  */
19
- export declare function parseLuxonDateTime<const SpecificTimezone extends Timezone>(dateTimeInput: Readonly<DateTime>, forcedTimezone?: SpecificTimezone): FullDate<SpecificTimezone>;
18
+ export declare function parseLuxonDateTime<const SpecificTimezone extends string>(dateTimeInput: Readonly<DateTime>, forcedTimezone?: SpecificTimezone): FullDate<SpecificTimezone>;
@@ -1,4 +1,4 @@
1
- import { applyBrand, omitObjectKeys } from '@augment-vir/common';
1
+ import { omitObjectKeys } from '@augment-vir/common';
2
2
  import { assertWrapDayOfMonth, assertWrapHour, assertWrapMillisecond, assertWrapMinute, assertWrapMonthNumber, assertWrapSecond, } from '@date-vir/duration';
3
3
  import { DateTime } from 'luxon';
4
4
  /**
@@ -30,11 +30,6 @@ export function parseLuxonDateTime(dateTimeInput, forcedTimezone) {
30
30
  if (!dateTimeInput.isValid) {
31
31
  throw new Error(`Invalid input: '${dateTimeInput.toISO()}'`);
32
32
  }
33
- const zoneName = dateTimeInput.zoneName;
34
- if (zoneName == undefined) {
35
- throw new Error('Valid Luxon dates must have a timezone.');
36
- }
37
- const brandedZoneName = applyBrand(zoneName);
38
33
  return {
39
34
  day: assertWrapDayOfMonth(dateTimeInput.day),
40
35
  month: assertWrapMonthNumber(dateTimeInput.month),
@@ -43,6 +38,6 @@ export function parseLuxonDateTime(dateTimeInput, forcedTimezone) {
43
38
  minute: assertWrapMinute(dateTimeInput.minute),
44
39
  second: assertWrapSecond(dateTimeInput.second),
45
40
  millisecond: assertWrapMillisecond(dateTimeInput.millisecond),
46
- timezone: forcedTimezone ?? brandedZoneName,
41
+ timezone: forcedTimezone ?? dateTimeInput.zoneName,
47
42
  };
48
43
  }
@@ -1,4 +1,3 @@
1
- import { type Timezone } from '../timezone/timezones.js';
2
1
  import { type DateLike } from './date-like.js';
3
2
  import { type FullDate } from './full-date-shape.js';
4
3
  /**
@@ -6,7 +5,7 @@ import { type FullDate } from './full-date-shape.js';
6
5
  * timezone. If the conversion fails or the input {@link DateLike} is empty, `undefined` is
7
6
  * returned.
8
7
  */
9
- export declare function maybeCreateFullDate<const SpecificTimezone extends Timezone>(
8
+ export declare function maybeCreateFullDate<const SpecificTimezone extends string>(
10
9
  /** The original date representation to be converted into a FullDate. */
11
10
  dateLike: Readonly<DateLike> | undefined | null,
12
11
  /** The timezone that this date/time is meant for / originated from. */
@@ -1,4 +1,3 @@
1
- import { type Timezone } from '../timezone/timezones.js';
2
1
  import { type FullDate } from './full-date-shape.js';
3
2
  /**
4
3
  * Parses any date string into a {@link FullDate} using the specified pattern and timezone. Prefer
@@ -12,7 +11,7 @@ import { type FullDate } from './full-date-shape.js';
12
11
  *
13
12
  * @category FullDate
14
13
  */
15
- export declare function parseDateStringWithPattern<const SpecificTimezone extends Timezone>({ dateString, formatString, timezone, }: {
14
+ export declare function parseDateStringWithPattern<const SpecificTimezone extends string>({ dateString, formatString, timezone, }: {
16
15
  /** The date string to be parsed. */
17
16
  dateString: string;
18
17
  /**
@@ -30,4 +29,4 @@ export declare function parseDateStringWithPattern<const SpecificTimezone extend
30
29
  * @category FullDate
31
30
  * @category HTML
32
31
  */
33
- export declare function parseInputElementValue<const SpecificTimezone extends Timezone>(elementOrValue: Readonly<Pick<HTMLInputElement, 'value'>> | string | null | undefined, timezone: SpecificTimezone): FullDate<SpecificTimezone> | undefined;
32
+ export declare function parseInputElementValue<const SpecificTimezone extends string>(elementOrValue: Readonly<Pick<HTMLInputElement, 'value'>> | string | null | undefined, timezone: SpecificTimezone): FullDate<SpecificTimezone> | undefined;
@@ -1,9 +1,8 @@
1
1
  import { DateTime } from 'luxon';
2
- import { type Timezone } from '../timezone/timezones.js';
3
2
  /**
4
3
  * Tries extra known formats for parsing date strings, even those that browsers do not natively
5
4
  * support.
6
5
  *
7
6
  * @category Internal
8
7
  */
9
- export declare function parseDateString(dateString: string, timezone: Timezone): DateTime | undefined;
8
+ export declare function parseDateString(dateString: string, timezone: string): DateTime | undefined;
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @virmator/prefer-params-object */
1
2
  import { DateTime } from 'luxon';
2
3
  /**
3
4
  * These formats are for luxon, documented here:
@@ -1,4 +1,3 @@
1
- import { type Timezone } from './timezones.js';
2
1
  /**
3
2
  * Checks that the given timezone is valid.
4
3
  *
@@ -8,7 +7,7 @@ import { type Timezone } from './timezones.js';
8
7
  *
9
8
  * @category Assertion
10
9
  */
11
- export declare function isValidTimezone(raw: string): raw is Timezone;
10
+ export declare function isValidTimezone(potentialTimezone: string): boolean;
12
11
  /**
13
12
  * Asserts that the given input is a valid timezone name.
14
13
  *
@@ -18,16 +17,4 @@ export declare function isValidTimezone(raw: string): raw is Timezone;
18
17
  *
19
18
  * @category Assertion
20
19
  */
21
- export declare function assertValidTimezone(raw: string, userMessage?: string | undefined): asserts raw is Timezone;
22
- /**
23
- * Asserts that the given input is a valid timezone name and returns it.
24
- *
25
- * @category Assertion
26
- */
27
- export declare function assertWrapValidTimezone(raw: string, userMessage?: string | undefined): Timezone;
28
- /**
29
- * Checks that the given input is a valid timezone name and returns it when valid.
30
- *
31
- * @category Assertion
32
- */
33
- export declare function checkWrapValidTimezone(raw: string): Timezone | undefined;
20
+ export declare function assertValidTimezone(potentialTimezone: string, userMessage?: string | undefined): void;
@@ -19,16 +19,16 @@ const ianaValidityCache = new Map();
19
19
  *
20
20
  * @category Assertion
21
21
  */
22
- export function isValidTimezone(raw) {
23
- if (knownTimezones.has(raw)) {
22
+ export function isValidTimezone(potentialTimezone) {
23
+ if (knownTimezones.has(potentialTimezone)) {
24
24
  return true;
25
25
  }
26
- const cached = ianaValidityCache.get(raw);
26
+ const cached = ianaValidityCache.get(potentialTimezone);
27
27
  if (cached != undefined) {
28
28
  return cached;
29
29
  }
30
- const isValid = Info.isValidIANAZone(raw);
31
- ianaValidityCache.set(raw, isValid);
30
+ const isValid = Info.isValidIANAZone(potentialTimezone);
31
+ ianaValidityCache.set(potentialTimezone, isValid);
32
32
  return isValid;
33
33
  }
34
34
  /**
@@ -40,25 +40,8 @@ export function isValidTimezone(raw) {
40
40
  *
41
41
  * @category Assertion
42
42
  */
43
- export function assertValidTimezone(raw, userMessage) {
44
- if (!isValidTimezone(raw)) {
45
- throw new AssertionError(`'${raw}' is not a valid time zone`, userMessage);
43
+ export function assertValidTimezone(potentialTimezone, userMessage) {
44
+ if (!isValidTimezone(potentialTimezone)) {
45
+ throw new AssertionError(`'${potentialTimezone}' is not a valid time zone`, userMessage);
46
46
  }
47
47
  }
48
- /**
49
- * Asserts that the given input is a valid timezone name and returns it.
50
- *
51
- * @category Assertion
52
- */
53
- export function assertWrapValidTimezone(raw, userMessage) {
54
- assertValidTimezone(raw, userMessage);
55
- return raw;
56
- }
57
- /**
58
- * Checks that the given input is a valid timezone name and returns it when valid.
59
- *
60
- * @category Assertion
61
- */
62
- export function checkWrapValidTimezone(raw) {
63
- return isValidTimezone(raw) ? raw : undefined;
64
- }
@@ -1,13 +1,12 @@
1
- import { type Timezone } from './timezones.js';
2
1
  /**
3
2
  * A shape for a timezone value.
4
3
  *
5
4
  * Unlike a strict enum check against the typed {@link Timezone} list, this validates at runtime via
6
5
  * {@link isValidTimezone} (i.e. any valid IANA zone name). It therefore accepts valid IANA names
7
6
  * that aren't in the typed list, such as legacy aliases like `'America/Indianapolis'` that some
8
- * environments (notably Safari) still report from `Intl`. The branded {@link Timezone} type allows
9
- * timezone inputs that are not restricted to the {@link Timezone} list.
7
+ * environments (notably Safari) still report from `Intl`. The static type is `string` so that
8
+ * timezone inputs are not restricted to the {@link Timezone} enum.
10
9
  *
11
10
  * @category Shape
12
11
  */
13
- export declare const timezoneShape: (defaultValue?: Timezone | undefined) => import("object-shape-tester").Shape<import("@sinclair/typebox").TUnsafe<Timezone>>;
12
+ export declare const timezoneShape: (defaultValue?: string | undefined) => import("object-shape-tester").Shape<import("@sinclair/typebox").TUnsafe<string>>;
@@ -8,8 +8,8 @@ import { utcTimezone } from './timezones.js';
8
8
  * Unlike a strict enum check against the typed {@link Timezone} list, this validates at runtime via
9
9
  * {@link isValidTimezone} (i.e. any valid IANA zone name). It therefore accepts valid IANA names
10
10
  * that aren't in the typed list, such as legacy aliases like `'America/Indianapolis'` that some
11
- * environments (notably Safari) still report from `Intl`. The branded {@link Timezone} type allows
12
- * timezone inputs that are not restricted to the {@link Timezone} list.
11
+ * environments (notably Safari) still report from `Intl`. The static type is `string` so that
12
+ * timezone inputs are not restricted to the {@link Timezone} enum.
13
13
  *
14
14
  * @category Shape
15
15
  */
@@ -1,25 +1,12 @@
1
- import { type ArrayElement, type Branded } from '@augment-vir/common';
1
+ import { type ArrayElement } from '@augment-vir/common';
2
2
  import { allTimezoneNames } from './timezone-names.js';
3
3
  /**
4
- * All known timezone names.
4
+ * All possible timezone names.
5
5
  *
6
6
  * @category Timezone
7
7
  * @see {@link allTimezoneNames}
8
8
  */
9
- export type TimezoneName = ArrayElement<typeof allTimezoneNames>;
10
- /**
11
- * A branded string for any timezone
12
- *
13
- * @category Timezone
14
- * @see {@link allTimezoneNames}
15
- */
16
- export type TimezoneString = Branded<string, 'timezone-string'>;
17
- /**
18
- * Any known or unknown timezone.
19
- *
20
- * @category Timezone
21
- */
22
- export type Timezone = TimezoneString | TimezoneName;
9
+ export type Timezone = ArrayElement<typeof allTimezoneNames>;
23
10
  /**
24
11
  * An enum of all possible timezone names.
25
12
  *
@@ -27,20 +14,20 @@ export type Timezone = TimezoneString | TimezoneName;
27
14
  * @example
28
15
  *
29
16
  * ```ts
30
- * import {TimezoneName} from 'date-vir';
17
+ * import {Timezone} from 'date-vir';
31
18
  *
32
- * TimezoneName['Africa/Bamako'];
19
+ * Timezone['Africa/Bamako'];
33
20
  * ```
34
21
  */
35
- export declare const TimezoneName: Readonly<{
36
- [SpecificTimezoneName in TimezoneName]: SpecificTimezoneName;
22
+ export declare const Timezone: Readonly<{
23
+ [SpecificTimezoneName in Timezone]: SpecificTimezoneName;
37
24
  }>;
38
25
  /**
39
26
  * The timezone of the current user's environment.
40
27
  *
41
28
  * @category Timezone
42
29
  */
43
- export declare const userTimezone: NoInfer<TimezoneString>;
30
+ export declare const userTimezone: string;
44
31
  /**
45
32
  * The UTC timezone.
46
33
  *
@@ -1,4 +1,3 @@
1
- import { applyBrand } from '@augment-vir/common';
2
1
  import { Settings } from 'luxon';
3
2
  import { allTimezoneNames } from './timezone-names.js';
4
3
  /**
@@ -8,12 +7,12 @@ import { allTimezoneNames } from './timezone-names.js';
8
7
  * @example
9
8
  *
10
9
  * ```ts
11
- * import {TimezoneName} from 'date-vir';
10
+ * import {Timezone} from 'date-vir';
12
11
  *
13
- * TimezoneName['Africa/Bamako'];
12
+ * Timezone['Africa/Bamako'];
14
13
  * ```
15
14
  */
16
- export const TimezoneName = allTimezoneNames.reduce((accum, timezoneName) => {
15
+ export const Timezone = allTimezoneNames.reduce((accum, timezoneName) => {
17
16
  accum[timezoneName] = timezoneName;
18
17
  return accum;
19
18
  }, {});
@@ -22,10 +21,10 @@ export const TimezoneName = allTimezoneNames.reduce((accum, timezoneName) => {
22
21
  *
23
22
  * @category Timezone
24
23
  */
25
- export const userTimezone = applyBrand(Settings.defaultZone.name);
24
+ export const userTimezone = Settings.defaultZone.name;
26
25
  /**
27
26
  * The UTC timezone.
28
27
  *
29
28
  * @category Timezone
30
29
  */
31
- export const utcTimezone = TimezoneName.UTC;
30
+ export const utcTimezone = Timezone.UTC;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "date-vir",
3
- "version": "8.6.3",
3
+ "version": "8.6.4",
4
4
  "description": "Easy and explicit dates and times.",
5
5
  "keywords": [
6
6
  "date",
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "@augment-vir/assert": "^32.2.1",
39
39
  "@augment-vir/common": "^32.2.1",
40
- "@date-vir/duration": "^8.6.3",
40
+ "@date-vir/duration": "^8.6.4",
41
41
  "@types/luxon": "^3.7.3",
42
42
  "luxon": "^3.7.2",
43
43
  "object-shape-tester": "^6.14.1",