Skip to content

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Mar 2, 2025
1 parent 95ea6c5 commit f241bfe
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/core/src/useDateTimeField/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,19 @@ export function isNumericByDefault(type: DateTimeSegmentType) {
return map[type] ?? false;
}

export function getOrderedSegmentTypes(): DateTimeSegmentType[] {
type EditableSegmentType = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second';

export function getOrderedSegmentTypes(): EditableSegmentType[] {
return ['year', 'month', 'day', 'hour', 'minute', 'second'];
}

export function isEqualPart(min: ZonedDateTime, max: ZonedDateTime, part: DateTimeSegmentType) {
const editablePart = part as EditableSegmentType;
const parts = getOrderedSegmentTypes();
const idx = parts.indexOf(part);
const idx = parts.indexOf(editablePart);
if (idx === -1) {
return false;
}

return parts.slice(0, idx).every(p => min[p] === max[p]) && min[part] === max[part];
return parts.slice(0, idx).every(p => min[p] === max[p]) && min[editablePart] === max[editablePart];
}

0 comments on commit f241bfe

Please sign in to comment.