date-vir 1.0.0 → 2.0.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.
Files changed (104) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/date-operations/calculate-relative-date.js +6 -2
  3. package/dist/cjs/date-operations/combine-dates.js +5 -0
  4. package/dist/cjs/{full-date → extra-utils}/js-date-conversion.js +1 -1
  5. package/dist/cjs/extra-utils/{now-in-iso-string.js → now.js} +5 -1
  6. package/dist/cjs/extra-utils/zero.js +30 -0
  7. package/dist/cjs/full-date/full-date-shape.js +14 -3
  8. package/dist/cjs/index.js +5 -3
  9. package/dist/esm/date-operations/calculate-relative-date.d.ts +6 -2
  10. package/dist/esm/date-operations/calculate-relative-date.js +6 -2
  11. package/dist/esm/date-operations/combine-dates.d.ts +2 -5
  12. package/dist/esm/date-operations/combine-dates.js +5 -0
  13. package/dist/esm/date-operations/diff-dates.d.ts +3 -5
  14. package/dist/esm/duration.d.ts +11 -0
  15. package/dist/esm/{full-date → extra-utils}/date-transforms.d.ts +1 -1
  16. package/dist/esm/{full-date → extra-utils}/js-date-conversion.d.ts +1 -1
  17. package/dist/esm/{full-date → extra-utils}/js-date-conversion.js +1 -1
  18. package/dist/esm/extra-utils/{now-in-iso-string.d.ts → now.d.ts} +2 -0
  19. package/dist/esm/extra-utils/{now-in-iso-string.js → now.js} +4 -1
  20. package/dist/esm/extra-utils/zero.d.ts +21 -0
  21. package/dist/esm/extra-utils/zero.js +25 -0
  22. package/dist/esm/full-date/full-date-shape.d.ts +5 -1
  23. package/dist/esm/full-date/full-date-shape.js +13 -2
  24. package/dist/esm/index.d.ts +5 -3
  25. package/dist/esm/index.js +5 -3
  26. package/docs-dist/assets/highlight.css +92 -0
  27. package/docs-dist/assets/main.js +59 -0
  28. package/docs-dist/assets/navigation.js +1 -0
  29. package/docs-dist/assets/search.js +1 -0
  30. package/docs-dist/assets/style.css +1383 -0
  31. package/docs-dist/enums/DiffUnit.html +126 -0
  32. package/docs-dist/enums/FullDatePartEnum.html +102 -0
  33. package/docs-dist/functions/assertIsValidFullDate.html +72 -0
  34. package/docs-dist/functions/assertValidTimezone.html +78 -0
  35. package/docs-dist/functions/calculateRelativeDate.html +78 -0
  36. package/docs-dist/functions/clearParts.html +74 -0
  37. package/docs-dist/functions/clearTime.html +72 -0
  38. package/docs-dist/functions/combineDateParts.html +197 -0
  39. package/docs-dist/functions/createFullDate.html +89 -0
  40. package/docs-dist/functions/createFullDateInUserTimezone.html +72 -0
  41. package/docs-dist/functions/createUtcFullDate.html +72 -0
  42. package/docs-dist/functions/diffDates.html +84 -0
  43. package/docs-dist/functions/getNowFullDate.html +77 -0
  44. package/docs-dist/functions/getNowInIsoString.html +67 -0
  45. package/docs-dist/functions/getNowInUserTimezone.html +67 -0
  46. package/docs-dist/functions/hasTimezone.html +79 -0
  47. package/docs-dist/functions/isDateAfter.html +77 -0
  48. package/docs-dist/functions/isValidFullDate.html +72 -0
  49. package/docs-dist/functions/isValidIsoString.html +72 -0
  50. package/docs-dist/functions/isValidTimezone.html +78 -0
  51. package/docs-dist/functions/overrideDateParts.html +77 -0
  52. package/docs-dist/functions/parseInputElementValue.html +83 -0
  53. package/docs-dist/functions/parseLuxonDateTime.html +84 -0
  54. package/docs-dist/functions/parseStrangeString.html +96 -0
  55. package/docs-dist/functions/toFormattedString.html +82 -0
  56. package/docs-dist/functions/toHtmlInputString.html +193 -0
  57. package/docs-dist/functions/toIsoString.html +75 -0
  58. package/docs-dist/functions/toJsDate.html +72 -0
  59. package/docs-dist/functions/toLocaleString.html +77 -0
  60. package/docs-dist/functions/toLuxonDateTime.html +77 -0
  61. package/docs-dist/functions/toNewTimezone.html +83 -0
  62. package/docs-dist/functions/toTimestamp.html +75 -0
  63. package/docs-dist/modules.html +139 -0
  64. package/docs-dist/types/AnyDuration.html +66 -0
  65. package/docs-dist/types/DateFullDateKeys.html +63 -0
  66. package/docs-dist/types/DateLike.html +66 -0
  67. package/docs-dist/types/DatePart.html +68 -0
  68. package/docs-dist/types/DateTimeString.html +63 -0
  69. package/docs-dist/types/DateTimeWithSeconds.html +63 -0
  70. package/docs-dist/types/Duration.html +73 -0
  71. package/docs-dist/types/FullDate.html +77 -0
  72. package/docs-dist/types/JustDateString.html +63 -0
  73. package/docs-dist/types/JustTimeString.html +63 -0
  74. package/docs-dist/types/JustTimeWithSecondsString.html +63 -0
  75. package/docs-dist/types/MaybeDatePart.html +66 -0
  76. package/docs-dist/types/MaybeTuple.html +68 -0
  77. package/docs-dist/types/OnlyDatePart.html +63 -0
  78. package/docs-dist/types/OnlyHourMinutePart.html +63 -0
  79. package/docs-dist/types/OnlyHourMinuteSecondPart.html +63 -0
  80. package/docs-dist/types/TimeFullDateKeys.html +63 -0
  81. package/docs-dist/types/TimePart.html +68 -0
  82. package/docs-dist/types/Timezone.html +63 -0
  83. package/docs-dist/types/Timezones.html +63 -0
  84. package/docs-dist/types/UtcIsoString.html +63 -0
  85. package/docs-dist/types/UtcTimezone.html +63 -0
  86. package/docs-dist/variables/allTimezoneNames.html +68 -0
  87. package/docs-dist/variables/dateFullDateKeys-1.html +63 -0
  88. package/docs-dist/variables/datePartShape.html +89 -0
  89. package/docs-dist/variables/formatPresets.html +114 -0
  90. package/docs-dist/variables/fullDateShape.html +63 -0
  91. package/docs-dist/variables/timeFullDateKeys-1.html +63 -0
  92. package/docs-dist/variables/timePartShape.html +91 -0
  93. package/docs-dist/variables/timezones-1.html +1005 -0
  94. package/docs-dist/variables/userLocale.html +63 -0
  95. package/docs-dist/variables/userTimezone.html +66 -0
  96. package/docs-dist/variables/utcTimezone-1.html +66 -0
  97. package/docs-dist/variables/zeroDate.html +80 -0
  98. package/docs-dist/variables/zeroTime.html +63 -0
  99. package/package.json +14 -12
  100. package/dist/esm/relative-time-duration.d.ts +0 -2
  101. /package/dist/cjs/{relative-time-duration.js → duration.js} +0 -0
  102. /package/dist/cjs/{full-date → extra-utils}/date-transforms.js +0 -0
  103. /package/dist/esm/{relative-time-duration.js → duration.js} +0 -0
  104. /package/dist/esm/{full-date → extra-utils}/date-transforms.js +0 -0
package/README.md CHANGED
@@ -4,6 +4,8 @@ Easy dates and times with explicit timezones (and typed timezones).
4
4
 
5
5
  `date-vir` revolves around the new `FullDate` type, which includes all the information you need to correctly pinpoint _and_ format a given point in time. Most notably, `FullDate` always includes a `timezone` property, so you _always_ know what timezone the date was originally defined in, or what timezone the date is intended to be used in:
6
6
 
7
+ Full docs: http://electrovir.github.io/date-vir
8
+
7
9
  <!-- example-link: src/readme-examples/full-date.example.ts -->
8
10
 
9
11
  ```TypeScript
@@ -2,7 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.calculateRelativeDate = void 0;
4
4
  const luxon_date_time_conversion_1 = require("../full-date/luxon-date-time-conversion");
5
- function calculateRelativeDate(fullDate, relativeCalculation) {
6
- return (0, luxon_date_time_conversion_1.parseLuxonDateTime)((0, luxon_date_time_conversion_1.toLuxonDateTime)(fullDate).plus(relativeCalculation));
5
+ /**
6
+ * Calculates a new date starting at the given fullDate and adding the given offsets. Offsets can be
7
+ * negative to go backwards in time.
8
+ */
9
+ function calculateRelativeDate(fullDate, offset) {
10
+ return (0, luxon_date_time_conversion_1.parseLuxonDateTime)((0, luxon_date_time_conversion_1.toLuxonDateTime)(fullDate).plus(offset));
7
11
  }
8
12
  exports.calculateRelativeDate = calculateRelativeDate;
@@ -3,6 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.combineDateParts = void 0;
4
4
  const object_shape_tester_1 = require("object-shape-tester");
5
5
  const full_date_shape_1 = require("../full-date/full-date-shape");
6
+ /**
7
+ * Combine two parts of a FullDate objects into a filled-in FullDate. Note that the timezones must
8
+ * match for both inputs. If two complete FullDate objects are passed in, only the respective parts
9
+ * of each is used.
10
+ */
6
11
  function combineDateParts(maybeDateParts) {
7
12
  const timePart = (0, object_shape_tester_1.isValidShape)(maybeDateParts.time, full_date_shape_1.timePartShape, {
8
13
  allowExtraKeys: true,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toJsDate = void 0;
4
- const primitive_conversions_1 = require("./primitive-conversions");
4
+ const primitive_conversions_1 = require("../full-date/primitive-conversions");
5
5
  function toJsDate(fullDate) {
6
6
  return new Date((0, primitive_conversions_1.toTimestamp)(fullDate));
7
7
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNowInIsoString = void 0;
3
+ exports.getNowInUserTimezone = exports.getNowInIsoString = void 0;
4
4
  const create_full_date_1 = require("../full-date/create-full-date");
5
5
  const primitive_conversions_1 = require("../full-date/primitive-conversions");
6
6
  const timezones_1 = require("../timezone/timezones");
@@ -12,3 +12,7 @@ function getNowInIsoString() {
12
12
  return (0, primitive_conversions_1.toIsoString)((0, create_full_date_1.getNowFullDate)(timezones_1.utcTimezone));
13
13
  }
14
14
  exports.getNowInIsoString = getNowInIsoString;
15
+ function getNowInUserTimezone() {
16
+ return (0, create_full_date_1.getNowFullDate)(timezones_1.userTimezone);
17
+ }
18
+ exports.getNowInUserTimezone = getNowInUserTimezone;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clearParts = exports.clearTime = exports.zeroTime = exports.zeroDate = void 0;
4
+ const common_1 = require("@augment-vir/common");
5
+ const full_date_shape_1 = require("../full-date/full-date-shape");
6
+ const date_transforms_1 = require("./date-transforms");
7
+ exports.zeroDate = {
8
+ year: 0,
9
+ month: 1,
10
+ day: 1,
11
+ hour: 0,
12
+ minute: 0,
13
+ second: 0,
14
+ millisecond: 0,
15
+ };
16
+ exports.zeroTime = (0, common_1.pickObjectKeys)(exports.zeroDate, full_date_shape_1.timeFullDateKeys);
17
+ function clearTime(inputFullDate) {
18
+ return clearParts(inputFullDate, full_date_shape_1.timeFullDateKeys);
19
+ }
20
+ exports.clearTime = clearTime;
21
+ function clearParts(inputFullDate, parts) {
22
+ const clearParts = (0, common_1.typedObjectFromEntries)(parts.map((keyName) => {
23
+ return [
24
+ keyName,
25
+ exports.zeroDate[keyName],
26
+ ];
27
+ }));
28
+ return (0, date_transforms_1.overrideDateParts)(inputFullDate, clearParts);
29
+ }
30
+ exports.clearParts = clearParts;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fullDateShape = exports.datePartShape = exports.timePartShape = exports.FullDatePartEnum = void 0;
3
+ exports.fullDateShape = exports.datePartShape = exports.timePartShape = exports.dateFullDateKeys = exports.timeFullDateKeys = exports.FullDatePartEnum = void 0;
4
4
  const object_shape_tester_1 = require("object-shape-tester");
5
5
  const timezones_1 = require("../timezone/timezones");
6
6
  /**
@@ -13,15 +13,26 @@ var FullDatePartEnum;
13
13
  FullDatePartEnum["Time"] = "time";
14
14
  FullDatePartEnum["DateTime"] = "datetime-local";
15
15
  })(FullDatePartEnum || (exports.FullDatePartEnum = FullDatePartEnum = {}));
16
+ exports.timeFullDateKeys = [
17
+ 'hour',
18
+ 'minute',
19
+ 'second',
20
+ 'millisecond',
21
+ ];
22
+ exports.dateFullDateKeys = [
23
+ 'year',
24
+ 'month',
25
+ 'day',
26
+ ];
16
27
  exports.timePartShape = (0, object_shape_tester_1.defineShape)({
17
28
  /** Hour of the day in 24 time: 0-23 */
18
29
  hour: 14,
19
30
  /** Minute of the hour: 0-59 */
20
31
  minute: 19,
21
32
  /** Second of the minute: 0-59 */
22
- second: 0,
33
+ second: 7,
23
34
  /** Millisecond of the second: 0-999 */
24
- millisecond: 870,
35
+ millisecond: 877,
25
36
  /** The timezone that this date/time is meant for / originated from. */
26
37
  timezone: timezones_1.utcTimezone,
27
38
  });
package/dist/cjs/index.js CHANGED
@@ -17,14 +17,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./date-operations/calculate-relative-date"), exports);
18
18
  __exportStar(require("./date-operations/combine-dates"), exports);
19
19
  __exportStar(require("./date-operations/diff-dates"), exports);
20
- __exportStar(require("./extra-utils/now-in-iso-string"), exports);
20
+ __exportStar(require("./duration"), exports);
21
+ __exportStar(require("./extra-utils/date-transforms"), exports);
22
+ __exportStar(require("./extra-utils/js-date-conversion"), exports);
23
+ __exportStar(require("./extra-utils/now"), exports);
24
+ __exportStar(require("./extra-utils/zero"), exports);
21
25
  __exportStar(require("./full-date/create-full-date"), exports);
22
26
  __exportStar(require("./full-date/date-like"), exports);
23
- __exportStar(require("./full-date/date-transforms"), exports);
24
27
  __exportStar(require("./full-date/format-presets"), exports);
25
28
  __exportStar(require("./full-date/full-date-shape"), exports);
26
29
  __exportStar(require("./full-date/is-valid-full-date"), exports);
27
- __exportStar(require("./full-date/js-date-conversion"), exports);
28
30
  __exportStar(require("./full-date/luxon-date-time-conversion"), exports);
29
31
  __exportStar(require("./full-date/parsing"), exports);
30
32
  __exportStar(require("./full-date/primitive-conversions"), exports);
@@ -1,3 +1,7 @@
1
+ import { AnyDuration } from '../duration';
1
2
  import { FullDate } from '../full-date/full-date-shape';
2
- import { RelativeTimeDuration } from '../relative-time-duration';
3
- export declare function calculateRelativeDate(fullDate: FullDate, relativeCalculation: RelativeTimeDuration): FullDate;
3
+ /**
4
+ * Calculates a new date starting at the given fullDate and adding the given offsets. Offsets can be
5
+ * negative to go backwards in time.
6
+ */
7
+ export declare function calculateRelativeDate(fullDate: Readonly<FullDate>, offset: Readonly<AnyDuration>): FullDate;
@@ -1,4 +1,8 @@
1
1
  import { parseLuxonDateTime, toLuxonDateTime } from '../full-date/luxon-date-time-conversion';
2
- export function calculateRelativeDate(fullDate, relativeCalculation) {
3
- return parseLuxonDateTime(toLuxonDateTime(fullDate).plus(relativeCalculation));
2
+ /**
3
+ * Calculates a new date starting at the given fullDate and adding the given offsets. Offsets can be
4
+ * negative to go backwards in time.
5
+ */
6
+ export function calculateRelativeDate(fullDate, offset) {
7
+ return parseLuxonDateTime(toLuxonDateTime(fullDate).plus(offset));
4
8
  }
@@ -1,14 +1,11 @@
1
1
  import { DatePart, FullDate, FullDatePartEnum, TimePart } from '../full-date/full-date-shape';
2
+ /** An object containing date and/or time parts or neither. */
2
3
  type MaybeDateParts = Partial<{
3
4
  [FullDatePartEnum.Date]: DatePart | undefined | Partial<FullDate>;
4
5
  [FullDatePartEnum.Time]: TimePart | undefined | Partial<FullDate>;
5
6
  }>;
7
+ /** A full date, time or date parts of a date, or undefined. */
6
8
  export type MaybeDatePart = FullDate | Partial<FullDate> | DatePart | TimePart | undefined;
7
- /**
8
- * Combine two parts of a FullDate objects into a filled-in FullDate. Note that the timezones must
9
- * match for both inputs. If two complete FullDate objects are passed in, only the respective parts
10
- * of each is used.
11
- */
12
9
  export declare function combineDateParts(maybeDateParts: {
13
10
  [FullDatePartEnum.Date]: DatePart;
14
11
  [FullDatePartEnum.Time]: TimePart;
@@ -1,5 +1,10 @@
1
1
  import { isValidShape } from 'object-shape-tester';
2
2
  import { FullDatePartEnum, datePartShape, timePartShape, } from '../full-date/full-date-shape';
3
+ /**
4
+ * Combine two parts of a FullDate objects into a filled-in FullDate. Note that the timezones must
5
+ * match for both inputs. If two complete FullDate objects are passed in, only the respective parts
6
+ * of each is used.
7
+ */
3
8
  export function combineDateParts(maybeDateParts) {
4
9
  const timePart = isValidShape(maybeDateParts.time, timePartShape, {
5
10
  allowExtraKeys: true,
@@ -1,6 +1,6 @@
1
- import { AtLeastTuple, RequiredAndNotNull } from '@augment-vir/common';
1
+ import { AtLeastTuple } from '@augment-vir/common';
2
+ import { Duration } from '../duration';
2
3
  import { FullDate } from '../full-date/full-date-shape';
3
- import { RelativeTimeDuration } from '../relative-time-duration';
4
4
  export type MaybeTuple<T> = T | AtLeastTuple<T, 1>;
5
5
  /**
6
6
  * Exclude the higher order units of time measure for diffing because they vary significantly,
@@ -18,13 +18,11 @@ export declare enum DiffUnit {
18
18
  Seconds = "seconds",
19
19
  Milliseconds = "milliseconds"
20
20
  }
21
- export type DiffDuration<DurationKeys extends MaybeTuple<DiffUnit>> = MaybeTuple<DiffUnit> extends DurationKeys ? Pick<RelativeTimeDuration, DiffUnit> : Pick<RequiredAndNotNull<RelativeTimeDuration>, DurationKeys extends AtLeastTuple<infer InnerValue, 1> ? InnerValue : DurationKeys>;
22
- export type Duration<DurationKeys extends MaybeTuple<DiffUnit>> = DiffDuration<DurationKeys>;
23
21
  export declare function diffDates<const DurationKeys extends MaybeTuple<DiffUnit> = MaybeTuple<DiffUnit>>({ start, end, unit, }: {
24
22
  start: FullDate;
25
23
  end: FullDate;
26
24
  unit: DurationKeys;
27
- }): DiffDuration<DurationKeys>;
25
+ }): Duration<DurationKeys>;
28
26
  export declare function isDateAfter({ start, end }: {
29
27
  start: FullDate;
30
28
  end: FullDate;
@@ -0,0 +1,11 @@
1
+ import { AtLeastTuple, RequiredAndNotNull } from '@augment-vir/common';
2
+ import { DurationObjectUnits } from 'luxon';
3
+ import { DiffUnit, MaybeTuple } from './date-operations/diff-dates';
4
+ /** All possible options for the more strict Duration type. */
5
+ export type AnyDuration = DurationObjectUnits;
6
+ /**
7
+ * Not a single date instance, but a description of a date duration. Used to calculate diffs between
8
+ * dates, or add offsets to an existing date, or describe a single time duration. Usually only one
9
+ * property is set on this at any given time.
10
+ */
11
+ export type Duration<DurationKeys extends MaybeTuple<DiffUnit>> = MaybeTuple<DiffUnit> extends DurationKeys ? Pick<AnyDuration, DiffUnit> : Pick<RequiredAndNotNull<AnyDuration>, DurationKeys extends AtLeastTuple<infer InnerValue, 1> ? InnerValue : DurationKeys>;
@@ -1,3 +1,3 @@
1
- import { FullDate } from './full-date-shape';
1
+ import { FullDate } from '../full-date/full-date-shape';
2
2
  /** Override the initial provided FullDate with all subsequent FullDate parts. */
3
3
  export declare function overrideDateParts(date: FullDate, ...overrides: Partial<FullDate>[]): FullDate;
@@ -1,2 +1,2 @@
1
- import { FullDate } from './full-date-shape';
1
+ import { FullDate } from '../full-date/full-date-shape';
2
2
  export declare function toJsDate(fullDate: FullDate): Date;
@@ -1,4 +1,4 @@
1
- import { toTimestamp } from './primitive-conversions';
1
+ import { toTimestamp } from '../full-date/primitive-conversions';
2
2
  export function toJsDate(fullDate) {
3
3
  return new Date(toTimestamp(fullDate));
4
4
  }
@@ -1,2 +1,4 @@
1
+ import { FullDate } from '../full-date/full-date-shape';
1
2
  import { UtcIsoString } from '../full-date/string-format-types';
2
3
  export declare function getNowInIsoString(): UtcIsoString;
4
+ export declare function getNowInUserTimezone(): FullDate;
@@ -1,6 +1,6 @@
1
1
  import { getNowFullDate } from '../full-date/create-full-date';
2
2
  import { toIsoString } from '../full-date/primitive-conversions';
3
- import { utcTimezone } from '../timezone/timezones';
3
+ import { userTimezone, utcTimezone } from '../timezone/timezones';
4
4
  export function getNowInIsoString() {
5
5
  /**
6
6
  * The time zone doesn't matter here because the ISO string will be identical for a given date
@@ -8,3 +8,6 @@ export function getNowInIsoString() {
8
8
  */
9
9
  return toIsoString(getNowFullDate(utcTimezone));
10
10
  }
11
+ export function getNowInUserTimezone() {
12
+ return getNowFullDate(userTimezone);
13
+ }
@@ -0,0 +1,21 @@
1
+ import { FullDate } from '../full-date/full-date-shape';
2
+ export declare const zeroDate: {
3
+ readonly year: 0;
4
+ readonly month: 1;
5
+ readonly day: 1;
6
+ readonly hour: 0;
7
+ readonly minute: 0;
8
+ readonly second: 0;
9
+ readonly millisecond: 0;
10
+ };
11
+ export declare const zeroTime: Pick<{
12
+ year: 0;
13
+ month: 1;
14
+ day: 1;
15
+ hour: 0;
16
+ minute: 0;
17
+ second: 0;
18
+ millisecond: 0;
19
+ }, "hour" | "minute" | "second" | "millisecond">;
20
+ export declare function clearTime(inputFullDate: Readonly<FullDate>): FullDate;
21
+ export declare function clearParts(inputFullDate: Readonly<FullDate>, parts: ReadonlyArray<Exclude<keyof FullDate, 'timezone'>>): FullDate;
@@ -0,0 +1,25 @@
1
+ import { pickObjectKeys, typedObjectFromEntries } from '@augment-vir/common';
2
+ import { timeFullDateKeys } from '../full-date/full-date-shape';
3
+ import { overrideDateParts } from './date-transforms';
4
+ export const zeroDate = {
5
+ year: 0,
6
+ month: 1,
7
+ day: 1,
8
+ hour: 0,
9
+ minute: 0,
10
+ second: 0,
11
+ millisecond: 0,
12
+ };
13
+ export const zeroTime = pickObjectKeys(zeroDate, timeFullDateKeys);
14
+ export function clearTime(inputFullDate) {
15
+ return clearParts(inputFullDate, timeFullDateKeys);
16
+ }
17
+ export function clearParts(inputFullDate, parts) {
18
+ const clearParts = typedObjectFromEntries(parts.map((keyName) => {
19
+ return [
20
+ keyName,
21
+ zeroDate[keyName],
22
+ ];
23
+ }));
24
+ return overrideDateParts(inputFullDate, clearParts);
25
+ }
@@ -1,4 +1,4 @@
1
- import { Overwrite, RequiredBy } from '@augment-vir/common';
1
+ import { ArrayElement, Overwrite, RequiredBy } from '@augment-vir/common';
2
2
  import { Timezone } from '../timezone/timezone-names';
3
3
  /**
4
4
  * Represents various parts of a FullDate. Each value is also a valid "type" attribute for an
@@ -9,6 +9,10 @@ export declare enum FullDatePartEnum {
9
9
  Time = "time",
10
10
  DateTime = "datetime-local"
11
11
  }
12
+ export declare const timeFullDateKeys: readonly ["hour", "minute", "second", "millisecond"];
13
+ export type TimeFullDateKeys = ArrayElement<typeof timeFullDateKeys>;
14
+ export declare const dateFullDateKeys: readonly ["year", "month", "day"];
15
+ export type DateFullDateKeys = ArrayElement<typeof dateFullDateKeys>;
12
16
  export declare const timePartShape: import("object-shape-tester").ShapeDefinition<{
13
17
  /** Hour of the day in 24 time: 0-23 */
14
18
  hour: number;
@@ -10,15 +10,26 @@ export var FullDatePartEnum;
10
10
  FullDatePartEnum["Time"] = "time";
11
11
  FullDatePartEnum["DateTime"] = "datetime-local";
12
12
  })(FullDatePartEnum || (FullDatePartEnum = {}));
13
+ export const timeFullDateKeys = [
14
+ 'hour',
15
+ 'minute',
16
+ 'second',
17
+ 'millisecond',
18
+ ];
19
+ export const dateFullDateKeys = [
20
+ 'year',
21
+ 'month',
22
+ 'day',
23
+ ];
13
24
  export const timePartShape = defineShape({
14
25
  /** Hour of the day in 24 time: 0-23 */
15
26
  hour: 14,
16
27
  /** Minute of the hour: 0-59 */
17
28
  minute: 19,
18
29
  /** Second of the minute: 0-59 */
19
- second: 0,
30
+ second: 7,
20
31
  /** Millisecond of the second: 0-999 */
21
- millisecond: 870,
32
+ millisecond: 877,
22
33
  /** The timezone that this date/time is meant for / originated from. */
23
34
  timezone: utcTimezone,
24
35
  });
@@ -1,14 +1,16 @@
1
1
  export * from './date-operations/calculate-relative-date';
2
2
  export * from './date-operations/combine-dates';
3
3
  export * from './date-operations/diff-dates';
4
- export * from './extra-utils/now-in-iso-string';
4
+ export * from './duration';
5
+ export * from './extra-utils/date-transforms';
6
+ export * from './extra-utils/js-date-conversion';
7
+ export * from './extra-utils/now';
8
+ export * from './extra-utils/zero';
5
9
  export * from './full-date/create-full-date';
6
10
  export * from './full-date/date-like';
7
- export * from './full-date/date-transforms';
8
11
  export * from './full-date/format-presets';
9
12
  export * from './full-date/full-date-shape';
10
13
  export * from './full-date/is-valid-full-date';
11
- export * from './full-date/js-date-conversion';
12
14
  export * from './full-date/luxon-date-time-conversion';
13
15
  export * from './full-date/parsing';
14
16
  export * from './full-date/primitive-conversions';
package/dist/esm/index.js CHANGED
@@ -1,14 +1,16 @@
1
1
  export * from './date-operations/calculate-relative-date';
2
2
  export * from './date-operations/combine-dates';
3
3
  export * from './date-operations/diff-dates';
4
- export * from './extra-utils/now-in-iso-string';
4
+ export * from './duration';
5
+ export * from './extra-utils/date-transforms';
6
+ export * from './extra-utils/js-date-conversion';
7
+ export * from './extra-utils/now';
8
+ export * from './extra-utils/zero';
5
9
  export * from './full-date/create-full-date';
6
10
  export * from './full-date/date-like';
7
- export * from './full-date/date-transforms';
8
11
  export * from './full-date/format-presets';
9
12
  export * from './full-date/full-date-shape';
10
13
  export * from './full-date/is-valid-full-date';
11
- export * from './full-date/js-date-conversion';
12
14
  export * from './full-date/luxon-date-time-conversion';
13
15
  export * from './full-date/parsing';
14
16
  export * from './full-date/primitive-conversions';
@@ -0,0 +1,92 @@
1
+ :root {
2
+ --light-hl-0: #AF00DB;
3
+ --dark-hl-0: #C586C0;
4
+ --light-hl-1: #000000;
5
+ --dark-hl-1: #D4D4D4;
6
+ --light-hl-2: #001080;
7
+ --dark-hl-2: #9CDCFE;
8
+ --light-hl-3: #A31515;
9
+ --dark-hl-3: #CE9178;
10
+ --light-hl-4: #0000FF;
11
+ --dark-hl-4: #569CD6;
12
+ --light-hl-5: #0070C1;
13
+ --dark-hl-5: #4FC1FF;
14
+ --light-hl-6: #267F99;
15
+ --dark-hl-6: #4EC9B0;
16
+ --light-hl-7: #098658;
17
+ --dark-hl-7: #B5CEA8;
18
+ --light-hl-8: #008000;
19
+ --dark-hl-8: #6A9955;
20
+ --light-hl-9: #795E26;
21
+ --dark-hl-9: #DCDCAA;
22
+ --light-code-background: #FFFFFF;
23
+ --dark-code-background: #1E1E1E;
24
+ }
25
+
26
+ @media (prefers-color-scheme: light) { :root {
27
+ --hl-0: var(--light-hl-0);
28
+ --hl-1: var(--light-hl-1);
29
+ --hl-2: var(--light-hl-2);
30
+ --hl-3: var(--light-hl-3);
31
+ --hl-4: var(--light-hl-4);
32
+ --hl-5: var(--light-hl-5);
33
+ --hl-6: var(--light-hl-6);
34
+ --hl-7: var(--light-hl-7);
35
+ --hl-8: var(--light-hl-8);
36
+ --hl-9: var(--light-hl-9);
37
+ --code-background: var(--light-code-background);
38
+ } }
39
+
40
+ @media (prefers-color-scheme: dark) { :root {
41
+ --hl-0: var(--dark-hl-0);
42
+ --hl-1: var(--dark-hl-1);
43
+ --hl-2: var(--dark-hl-2);
44
+ --hl-3: var(--dark-hl-3);
45
+ --hl-4: var(--dark-hl-4);
46
+ --hl-5: var(--dark-hl-5);
47
+ --hl-6: var(--dark-hl-6);
48
+ --hl-7: var(--dark-hl-7);
49
+ --hl-8: var(--dark-hl-8);
50
+ --hl-9: var(--dark-hl-9);
51
+ --code-background: var(--dark-code-background);
52
+ } }
53
+
54
+ :root[data-theme='light'] {
55
+ --hl-0: var(--light-hl-0);
56
+ --hl-1: var(--light-hl-1);
57
+ --hl-2: var(--light-hl-2);
58
+ --hl-3: var(--light-hl-3);
59
+ --hl-4: var(--light-hl-4);
60
+ --hl-5: var(--light-hl-5);
61
+ --hl-6: var(--light-hl-6);
62
+ --hl-7: var(--light-hl-7);
63
+ --hl-8: var(--light-hl-8);
64
+ --hl-9: var(--light-hl-9);
65
+ --code-background: var(--light-code-background);
66
+ }
67
+
68
+ :root[data-theme='dark'] {
69
+ --hl-0: var(--dark-hl-0);
70
+ --hl-1: var(--dark-hl-1);
71
+ --hl-2: var(--dark-hl-2);
72
+ --hl-3: var(--dark-hl-3);
73
+ --hl-4: var(--dark-hl-4);
74
+ --hl-5: var(--dark-hl-5);
75
+ --hl-6: var(--dark-hl-6);
76
+ --hl-7: var(--dark-hl-7);
77
+ --hl-8: var(--dark-hl-8);
78
+ --hl-9: var(--dark-hl-9);
79
+ --code-background: var(--dark-code-background);
80
+ }
81
+
82
+ .hl-0 { color: var(--hl-0); }
83
+ .hl-1 { color: var(--hl-1); }
84
+ .hl-2 { color: var(--hl-2); }
85
+ .hl-3 { color: var(--hl-3); }
86
+ .hl-4 { color: var(--hl-4); }
87
+ .hl-5 { color: var(--hl-5); }
88
+ .hl-6 { color: var(--hl-6); }
89
+ .hl-7 { color: var(--hl-7); }
90
+ .hl-8 { color: var(--hl-8); }
91
+ .hl-9 { color: var(--hl-9); }
92
+ pre, code { background: var(--code-background); }