d2coreui 23.0.55 → 23.0.57

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 (36) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/components/date/dateRangeInput.js +5 -5
  3. package/components/date/dateRangeInput.js.map +1 -1
  4. package/components/date/dateRangeInputAdvancedPanel.js +26 -15
  5. package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
  6. package/components/date/dateRangeInputConfirm.js +16 -13
  7. package/components/date/dateRangeInputConfirm.js.map +1 -1
  8. package/components/date/dateTimeInput.d.ts +12 -3
  9. package/components/date/dateTimeInput.js +164 -93
  10. package/components/date/dateTimeInput.js.map +1 -1
  11. package/components/grid/config/dataGridEditor.d.ts +4 -3
  12. package/components/grid/config/dataGridEditor.js +16 -4
  13. package/components/grid/config/dataGridEditor.js.map +1 -1
  14. package/components/grid/dataGrid.d.ts +19 -5
  15. package/components/grid/dataGrid.js +9 -5
  16. package/components/grid/dataGrid.js.map +1 -1
  17. package/components/grid/export/contextMenu.d.ts +3 -2
  18. package/components/grid/export/contextMenu.js.map +1 -1
  19. package/components/grid/extendedDataGrid.d.ts +11 -4
  20. package/components/grid/extendedDataGrid.js +34 -24
  21. package/components/grid/extendedDataGrid.js.map +1 -1
  22. package/components/modal/impl/draggableModalInner.js +22 -10
  23. package/components/modal/impl/draggableModalInner.js.map +1 -1
  24. package/components/modal/impl/draggableModalReducer.d.ts +2 -3
  25. package/components/modal/impl/draggableModalReducer.js +9 -7
  26. package/components/modal/impl/draggableModalReducer.js.map +1 -1
  27. package/components/modal/modalDialog.d.ts +2 -1
  28. package/components/modal/modalDialog.js +2 -1
  29. package/components/modal/modalDialog.js.map +1 -1
  30. package/components/style/withCss.d.ts +9 -4
  31. package/components/style/withCss.js +7 -3
  32. package/components/style/withCss.js.map +1 -1
  33. package/i18n/components.cs.json +2 -0
  34. package/i18n/components.sk.json +2 -0
  35. package/i18n/components.uk.json +2 -0
  36. package/package.json +1 -1
@@ -23,77 +23,87 @@ import { createStyles } from "antd-style";
23
23
  import WithCss from "d2coreui/components/style/withCss";
24
24
  import i18n from "d2core/i18n/i18n";
25
25
  import { DEFAULT_FORMAT_CHARACTERS, ESCAPE_CHAR } from "d2coreui/components/input/mask/helpers";
26
+ import { AMBIGUOUS_HOUR_TOKEN, AMBIGUOUS_UTC_OFFSET_TOKEN, getWallClockInstants, replaceAmbiguousTimeTokens } from "d2core/dayjs/ambiguousTime";
26
27
  const useStyles = createStyles(({ token, css }, props) => {
27
28
  // antd colours prefix/suffix by status in every variant except borderless
28
29
  const statusAffix = props.variant !== "borderless";
29
30
  return {
30
- dateTimeInputCalendar: css `
31
- // adaptations of date-picker calendar styles
32
- .ant-picker-cell-in-view.ant-picker-cell-selected .ant-picker-cell-inner:not(.date-picker-item-marked) {
33
- color: inherit;
34
- background: inherit;
35
- }
36
-
37
- .ant-picker-panel:focus > .ant-picker-date-panel .ant-picker-cell-in-view.ant-picker-cell-selected .ant-picker-cell-inner:before {
38
- position: absolute;
39
- top: 0;
40
- right: 0;
41
- bottom: 0;
42
- left: 0;
43
- z-index: 1;
44
- border: ${token.lineWidth}px ${token.lineType} ${token.colorPrimary};
45
- border-radius: ${token.borderRadiusSM}px;
46
- content: '';
47
- }
48
-
49
- .ant-picker-content thead {
50
- user-select: none;
51
- }
52
-
53
- // plays the role of antd's selected cell
54
- .date-picker-item-marked {
55
- color: ${token.colorTextLightSolid};
56
- background: ${token.colorPrimary};
57
- }
58
-
59
- .ant-picker-cell-in-view.ant-picker-cell-today .ant-picker-cell-inner::before {
60
- border: ${token.lineWidth}px ${token.lineType} ${token.colorPrimary};
61
- }
62
-
63
- // antd's cellHoverBg, text colour is left untouched on hover
64
- .ant-picker-cell:hover:not(.ant-picker-cell-in-view) .ant-picker-cell-inner, .ant-picker-cell:hover:not(.ant-picker-cell-selected):not(.ant-picker-cell-range-start):not(.ant-picker-cell-range-end):not(.ant-picker-cell-range-hover-start):not(.ant-picker-cell-range-hover-end) .ant-picker-cell-inner {
65
- background: ${token.controlItemBgHover};
66
- }
67
-
68
- .ant-picker-body {
69
- padding-bottom: 0 !important;
70
- }
31
+ dateTimeInputCalendar: css `
32
+ // adaptations of date-picker calendar styles
33
+ .ant-picker-cell-in-view.ant-picker-cell-selected .ant-picker-cell-inner:not(.date-picker-item-marked) {
34
+ color: inherit;
35
+ background: inherit;
36
+ }
37
+
38
+ .ant-picker-panel:focus > .ant-picker-date-panel .ant-picker-cell-in-view.ant-picker-cell-selected .ant-picker-cell-inner:before {
39
+ position: absolute;
40
+ top: 0;
41
+ right: 0;
42
+ bottom: 0;
43
+ left: 0;
44
+ z-index: 1;
45
+ border: ${token.lineWidth}px ${token.lineType} ${token.colorPrimary};
46
+ border-radius: ${token.borderRadiusSM}px;
47
+ content: '';
48
+ }
49
+
50
+ .ant-picker-content thead {
51
+ user-select: none;
52
+ }
53
+
54
+ // plays the role of antd's selected cell
55
+ .date-picker-item-marked {
56
+ color: ${token.colorTextLightSolid};
57
+ background: ${token.colorPrimary};
58
+ }
59
+
60
+ .ant-picker-cell-in-view.ant-picker-cell-today .ant-picker-cell-inner::before {
61
+ border: ${token.lineWidth}px ${token.lineType} ${token.colorPrimary};
62
+ }
63
+
64
+ // antd's cellHoverBg, text colour is left untouched on hover
65
+ .ant-picker-cell:hover:not(.ant-picker-cell-in-view) .ant-picker-cell-inner, .ant-picker-cell:hover:not(.ant-picker-cell-selected):not(.ant-picker-cell-range-start):not(.ant-picker-cell-range-end):not(.ant-picker-cell-range-hover-start):not(.ant-picker-cell-range-hover-end) .ant-picker-cell-inner {
66
+ background: ${token.controlItemBgHover};
67
+ }
68
+
69
+ .ant-picker-body {
70
+ padding-bottom: 0 !important;
71
+ }
71
72
  `,
72
- suffixIcon: css `
73
- color: ${token.colorTextQuaternary};
74
- vertical-align: middle;
75
- height: 100%;
73
+ // the calendar icon is centred on this wrapper, not on the root, which a flex parent may stretch; as a block
74
+ // it would put the inline-block antd input on a line box and grow by the descender gap
75
+ inputWrapper: css `
76
+ display: flex;
77
+ position: relative;
78
+ `,
79
+ suffixIconHost: css `
80
+ display: flex;
81
+ align-items: center;
82
+ justify-content: center;
83
+ `,
84
+ suffixIcon: css `
85
+ color: ${token.colorTextQuaternary};
76
86
  `,
77
87
  // antd colours the affix by status - see `genOutlinedStatusStyle.affixColor`
78
- suffixIconError: css `
79
- ${statusAffix ? `color: ${token.colorError};` : ""}
88
+ suffixIconError: css `
89
+ ${statusAffix ? `color: ${token.colorError};` : ""}
80
90
  `,
81
- suffixIconWarning: css `
82
- ${statusAffix ? `color: ${token.colorWarning};` : ""}
91
+ suffixIconWarning: css `
92
+ ${statusAffix ? `color: ${token.colorWarning};` : ""}
83
93
  `,
84
- suffixIconDisabled: css `
85
- color: ${token.colorTextDisabled};
94
+ suffixIconDisabled: css `
95
+ color: ${token.colorTextDisabled};
86
96
  `,
87
97
  /**
88
98
  * antd's borderless/filled status styles colour the value text and are not guarded
89
99
  * against the disabled state - pickers keep colorTextDisabled, so match the picker.
90
100
  * Applied only for a truly disabled component, never for `inputDisabled` (open popup).
91
101
  */
92
- disabledText: css `
93
- && input[disabled] {
94
- color: ${token.colorTextDisabled};
95
- -webkit-text-fill-color: ${token.colorTextDisabled};
96
- }
102
+ disabledText: css `
103
+ && input[disabled] {
104
+ color: ${token.colorTextDisabled};
105
+ -webkit-text-fill-color: ${token.colorTextDisabled};
106
+ }
97
107
  `,
98
108
  };
99
109
  });
@@ -118,8 +128,11 @@ const OFFSET_TOKENS = [
118
128
  * a literal of the generated pattern - letters of the mask are always turned into field slots.
119
129
  */
120
130
  const SIGN_FORMAT_CHAR = "S";
121
- const SIGN_FORMAT_CHARACTERS = {
131
+ /** MaskedInput format character for the leading position of the `HH?` hour - a digit, or `A`/`B` of a DST fold. */
132
+ const HOUR_LETTER_FORMAT_CHAR = "F";
133
+ const MASK_FORMAT_CHARACTERS = {
122
134
  [SIGN_FORMAT_CHAR]: { validate: (char) => char === "+" || char === "-" },
135
+ [HOUR_LETTER_FORMAT_CHAR]: { validate: (char) => /^[0-9ABab]$/.test(char), transform: (char) => char.toUpperCase() },
123
136
  };
124
137
  const MAX_UTC_OFFSET_MINUTES = 14 * 60;
125
138
  const MIN_TIME = dayjs.unix(0);
@@ -151,10 +164,13 @@ function findInfoEntry(token) {
151
164
  return undefined;
152
165
  }
153
166
  function escapePatternChar(char) {
154
- return char in DEFAULT_FORMAT_CHARACTERS || char === SIGN_FORMAT_CHAR || char === ESCAPE_CHAR
167
+ return char in DEFAULT_FORMAT_CHARACTERS || char in MASK_FORMAT_CHARACTERS || char === ESCAPE_CHAR
155
168
  ? ESCAPE_CHAR + char
156
169
  : char;
157
170
  }
171
+ function toInputMask(mask) {
172
+ return replaceAmbiguousTimeTokens(mask, (token) => token === AMBIGUOUS_UTC_OFFSET_TOKEN ? "Z" : token);
173
+ }
158
174
  /**
159
175
  * Walks the mask once and records, for every editable field, where it lands in the value as
160
176
  * dayjs renders it. Both the MaskedInput pattern and the parser positions are derived from
@@ -177,6 +193,14 @@ function buildMaskLayout(mask) {
177
193
  i += offset.token.length;
178
194
  continue;
179
195
  }
196
+ if (mask.startsWith(AMBIGUOUS_HOUR_TOKEN, i)) {
197
+ const found = findInfoEntry("HH");
198
+ segments.push({ token: AMBIGUOUS_HOUR_TOKEN, index: renderIndex, length: 2, entry: found.entry, min: found.min, max: found.max });
199
+ pattern += HOUR_LETTER_FORMAT_CHAR + "1";
200
+ renderIndex += 2;
201
+ i += AMBIGUOUS_HOUR_TOKEN.length;
202
+ continue;
203
+ }
180
204
  const token = NUMBER_TOKENS.find((t) => mask.startsWith(t, i));
181
205
  const found = token !== undefined ? findInfoEntry(token) : undefined;
182
206
  if (token !== undefined && found !== undefined) {
@@ -195,6 +219,14 @@ function buildMaskLayout(mask) {
195
219
  }
196
220
  const CALENDAR_ICON_WIDTH = 28;
197
221
  let measureContext = null;
222
+ // CSS takes an unquoted family name only if it is made of identifiers - the canvas ignores the whole `font` when one
223
+ // is not (e.g. the token `fontFamily: "72"`) and keeps measuring in its default 10px font
224
+ function quoteFontFamilies(fontFamily) {
225
+ return fontFamily.split(",")
226
+ .map((family) => family.trim())
227
+ .map((family) => /^["']/.test(family) || /^-?[a-zA-Z_][\w-]*(\s+-?[a-zA-Z_][\w-]*)*$/.test(family) ? family : `"${family}"`)
228
+ .join(", ");
229
+ }
198
230
  function measureTextWidth(text, font) {
199
231
  measureContext !== null && measureContext !== void 0 ? measureContext : (measureContext = document.createElement("canvas").getContext("2d"));
200
232
  if (!measureContext) {
@@ -239,7 +271,7 @@ export default class DateTimeInput extends React.Component {
239
271
  }
240
272
  };
241
273
  this.layoutMask = props.mask;
242
- this.layout = buildMaskLayout(props.mask);
274
+ this.layout = buildMaskLayout(toInputMask(props.mask));
243
275
  this.state = {
244
276
  valid: DateTimeInput.isValidValue(props.value, props.minDateTime, props.maxDateTime, props.allowClear),
245
277
  currentPos: null,
@@ -289,10 +321,25 @@ export default class DateTimeInput extends React.Component {
289
321
  getLayout() {
290
322
  if (this.layoutMask !== this.props.mask) {
291
323
  this.layoutMask = this.props.mask;
292
- this.layout = buildMaskLayout(this.props.mask);
324
+ this.layout = buildMaskLayout(toInputMask(this.props.mask));
293
325
  }
294
326
  return this.layout;
295
327
  }
328
+ /**
329
+ * A typed text can stand for a value shown differently (`02` of a repeated hour is `B2`). When that value is the
330
+ * current one, the `value` prop does not change and MaskedInput would keep the typed text.
331
+ */
332
+ rewriteInputIfShownDifferently(inputString, time) {
333
+ const maskedInput = this.inputRef.current;
334
+ const shown = time.locale("locale.d2000").format(toInputMask(this.props.mask));
335
+ if (maskedInput === null || shown === inputString) {
336
+ return;
337
+ }
338
+ const { selectionStart, selectionEnd } = maskedInput.input;
339
+ maskedInput.mask.setValue(shown);
340
+ maskedInput.setInputValue(maskedInput.mask.getValue());
341
+ maskedInput.input.setSelectionRange(selectionStart, selectionEnd);
342
+ }
296
343
  /** Moves the keyboard focus to the text input. */
297
344
  focus() {
298
345
  var _a;
@@ -482,8 +529,10 @@ export default class DateTimeInput extends React.Component {
482
529
  */
483
530
  getInputTextWidth(fontFamily, fontSize) {
484
531
  // all digits as "0" so that the width holds for any value, not just today's
485
- const sample = dayjs().locale("locale.d2000").format(this.props.mask).replace(/\d/g, "0");
486
- return Math.ceil(measureTextWidth(sample, `${fontSize}px ${fontFamily}`));
532
+ // and as the widest hour of a DST fold
533
+ const mask = toInputMask(this.props.mask).replace(AMBIGUOUS_HOUR_TOKEN, "[B0]");
534
+ const sample = dayjs().locale("locale.d2000").format(mask).replace(/\d/g, "0");
535
+ return Math.ceil(measureTextWidth(sample, `${fontSize}px ${quoteFontFamilies(fontFamily)}`));
487
536
  }
488
537
  /** Renders the masked input with its calendar icon, without the popup. */
489
538
  renderInput() {
@@ -494,20 +543,22 @@ export default class DateTimeInput extends React.Component {
494
543
  // the root has to stay a plain DOM element - Tooltip in render() clones it to inject
495
544
  // its trigger handlers, and a WithCss root would swallow them
496
545
  return (React.createElement("div", Object.assign({ style: Object.assign(Object.assign(Object.assign({}, (autoWidth ? { width: "fit-content" } : {})), style), { position: "relative" }) }, props, { className: className }),
497
- React.createElement(WithCss, { useStyles: useStyles, props: { variant } }, ({ styles, cx, theme }) => {
546
+ React.createElement(WithCss, { useStyles: useStyles, props: { variant, size } }, ({ styles, cx, theme }, { size: mergedSize }) => {
498
547
  var _a;
499
548
  const maskedInputStyle = !this.state.valid ? { color: theme.colorError } : {};
500
549
  if (autoWidth) {
501
550
  Object.assign(maskedInputStyle, {
551
+ // the measured width is the minimum - the input still fills a root stretched by the caller
552
+ flexGrow: 1,
502
553
  boxSizing: "content-box",
503
- width: this.getInputTextWidth(theme.fontFamily, size === "large" ? theme.fontSizeLG : theme.fontSize),
554
+ width: this.getInputTextWidth(theme.fontFamily, mergedSize === "large" ? theme.fontSizeLG : theme.fontSize),
504
555
  }, !hidePopup && { paddingRight: CALENDAR_ICON_WIDTH });
505
556
  }
506
557
  if (inputStyle) {
507
558
  Object.assign(maskedInputStyle, inputStyle);
508
559
  }
509
560
  return (React.createElement(React.Fragment, null,
510
- React.createElement("div", { className: cx({ [styles.disabledText]: !!disabled }), onKeyDown: (event) => {
561
+ React.createElement("div", { className: cx(styles.inputWrapper, { [styles.disabledText]: !!disabled }), onKeyDown: (event) => {
511
562
  if (event.code === "ArrowUp") { // up
512
563
  this.increment();
513
564
  event.preventDefault();
@@ -519,7 +570,7 @@ export default class DateTimeInput extends React.Component {
519
570
  event.stopPropagation();
520
571
  }
521
572
  } },
522
- React.createElement(MaskedInput, { mask: this.getLayout().pattern, formatCharacters: SIGN_FORMAT_CHARACTERS, variant: variant, status: mergedStatus, ref: this.inputRef, style: maskedInputStyle, size: size, value: (this.state.focused || unix !== D2000UnixTimeNullValue * 1000) ? ((_a = value === null || value === void 0 ? void 0 : value.locale("locale.d2000").format(this.props.mask)) !== null && _a !== void 0 ? _a : "") : "", placeholder: (!this.state.focused && unix === D2000UnixTimeNullValue * 1000) ? "Null Time" : undefined, onFocus: (event => {
573
+ React.createElement(MaskedInput, { mask: this.getLayout().pattern, formatCharacters: MASK_FORMAT_CHARACTERS, variant: variant, status: mergedStatus, ref: this.inputRef, style: maskedInputStyle, size: size, value: (this.state.focused || unix !== D2000UnixTimeNullValue * 1000) ? ((_a = value === null || value === void 0 ? void 0 : value.locale("locale.d2000").format(toInputMask(this.props.mask))) !== null && _a !== void 0 ? _a : "") : "", placeholder: (!this.state.focused && unix === D2000UnixTimeNullValue * 1000) ? "Null Time" : undefined, onFocus: (event => {
523
574
  event.target.selectionStart = event.target.selectionEnd = this.state.currentPos;
524
575
  this.setState({ focused: true });
525
576
  }), onBlur: () => {
@@ -529,6 +580,7 @@ export default class DateTimeInput extends React.Component {
529
580
  const value = DateTimeInput.parseDateTimeFormat(this.props.value, inputString, this.getLayout(), event.target.selectionStart);
530
581
  const valid = DateTimeInput.isValidValue(value.time, this.props.minDateTime, this.props.maxDateTime, this.props.allowClear) || (!!this.props.allowClear && !inputString);
531
582
  if (value.time !== undefined && valid) {
583
+ this.rewriteInputIfShownDifferently(inputString, value.time);
532
584
  onChange === null || onChange === void 0 ? void 0 : onChange(value.time.clone());
533
585
  }
534
586
  else if (!!this.props.allowClear && !inputString) {
@@ -541,29 +593,28 @@ export default class DateTimeInput extends React.Component {
541
593
  valid: valid,
542
594
  currentInfo: value
543
595
  });
544
- } })),
545
- !hidePopup && !renderAsCalendar && React.createElement("div", { style: {
546
- width: CALENDAR_ICON_WIDTH,
547
- opacity: 1,
548
- height: "100%",
549
- textAlign: "center",
550
- cursor: disabled ? "not-allowed" : "pointer",
551
- background: "transparent",
552
- position: "absolute",
553
- top: 0,
554
- right: 0,
555
- }, onClick: (event) => {
556
- if (document.createEvent) {
557
- var ev = document.createEvent('HTMLEvents');
558
- ev.initEvent('contextmenu', true, false);
559
- event.target.dispatchEvent(ev);
560
- }
561
- } },
562
- React.createElement(CalendarOutlined, { className: cx(styles.suffixIcon, {
563
- [styles.suffixIconError]: !disabled && mergedStatus === "error",
564
- [styles.suffixIconWarning]: !disabled && mergedStatus === "warning",
565
- [styles.suffixIconDisabled]: !!disabled,
566
- }) }))));
596
+ } }),
597
+ !hidePopup && !renderAsCalendar && React.createElement("div", { className: styles.suffixIconHost, style: {
598
+ width: CALENDAR_ICON_WIDTH,
599
+ opacity: 1,
600
+ height: "100%",
601
+ cursor: disabled ? "not-allowed" : "pointer",
602
+ background: "transparent",
603
+ position: "absolute",
604
+ top: 0,
605
+ right: 0,
606
+ }, onClick: (event) => {
607
+ if (document.createEvent) {
608
+ var ev = document.createEvent('HTMLEvents');
609
+ ev.initEvent('contextmenu', true, false);
610
+ event.target.dispatchEvent(ev);
611
+ }
612
+ } },
613
+ React.createElement(CalendarOutlined, { className: cx(styles.suffixIcon, {
614
+ [styles.suffixIconError]: !disabled && mergedStatus === "error",
615
+ [styles.suffixIconWarning]: !disabled && mergedStatus === "warning",
616
+ [styles.suffixIconDisabled]: !!disabled,
617
+ }) })))));
567
618
  })));
568
619
  }
569
620
  render() {
@@ -632,6 +683,7 @@ export default class DateTimeInput extends React.Component {
632
683
  // fields the mask does not carry keep the value they have in `base`
633
684
  const nominal = DateTimeInput.toWallClock(base);
634
685
  let time = base;
686
+ let occurrence = undefined;
635
687
  // iterated in DATE_TIME_DATA_MAP order, not in mask order - the day has to be set after
636
688
  // the year and the month so that it is not clamped by the month it is temporarily in
637
689
  for (const v of DATE_TIME_DATA_MAP) {
@@ -639,7 +691,12 @@ export default class DateTimeInput extends React.Component {
639
691
  if (segment === undefined) {
640
692
  continue;
641
693
  }
642
- let val = Number(value.substring(segment.index, segment.index + segment.length));
694
+ let text = value.substring(segment.index, segment.index + segment.length);
695
+ if (segment.token === AMBIGUOUS_HOUR_TOKEN && (text[0] === "A" || text[0] === "B")) {
696
+ occurrence = text[0];
697
+ text = text.substring(1);
698
+ }
699
+ let val = Number(text);
643
700
  if (isNaN(val) || val < segment.min || val > segment.max) {
644
701
  return invalid;
645
702
  }
@@ -653,14 +710,28 @@ export default class DateTimeInput extends React.Component {
653
710
  nominal[v.part] = val;
654
711
  time = time === null || time === void 0 ? void 0 : time.set(v.unit === "d" ? 'D' : v.unit, val);
655
712
  }
656
- // `time` has already normalised a wall clock that does not exist - when the mask carries
657
- // the UTC offset, rebuild the instant from the typed reading instead, so that both sides
658
- // of a DST fold are reachable and a DST gap comes out invalid
713
+ // `time` has already rolled a wall clock that does not exist (DST gap, 31.02.) over to another one, so the
714
+ // instant is rebuilt from the typed reading - with the UTC offset when the mask carries it, so that both sides
715
+ // of a DST fold are reachable
659
716
  const offsetSegment = layout.segments.find((s) => s.entry === undefined);
660
717
  if (offsetSegment !== undefined) {
661
718
  const offset = DateTimeInput.parseUtcOffset(value.substring(offsetSegment.index, offsetSegment.index + offsetSegment.length));
662
719
  time = offset === undefined ? undefined : DateTimeInput.resolveWallClock(nominal, offset);
663
720
  }
721
+ else {
722
+ const utcMs = Date.UTC(nominal.y, nominal.M, nominal.D, nominal.h, nominal.m, nominal.s, nominal.ms);
723
+ const instants = getWallClockInstants(utcMs, (ms) => dayjs(ms))
724
+ .filter((instant) => DateTimeInput.isSameWallClock(DateTimeInput.toWallClock(instant), nominal));
725
+ if (occurrence !== undefined) {
726
+ time = instants.length === 2 ? instants[occurrence === "A" ? 0 : 1] : undefined;
727
+ }
728
+ else if (instants.length === 0) {
729
+ time = undefined;
730
+ }
731
+ else if (layout.segments.some((s) => s.token === AMBIGUOUS_HOUR_TOKEN)) {
732
+ time = instants[instants.length - 1];
733
+ }
734
+ }
664
735
  if (time === undefined) {
665
736
  return invalid;
666
737
  }