-
Notifications
You must be signed in to change notification settings - Fork 72
[LG-5532] feat(time-input): Segment state utils #3385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: LG-5532/segments-display-values
Are you sure you want to change the base?
[LG-5532] feat(time-input): Segment state utils #3385
Conversation
… from specified time zones
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces utility functions for managing time input segment state, including validation, formatting, and conversion between 12-hour and 24-hour formats. The implementation handles timezone conversions, segment validation, and provides comprehensive test coverage for UTC date creation from time segments.
- Adds utilities for validating and formatting time segments (hour, minute, second)
- Implements conversion logic between 12-hour and 24-hour time formats
- Introduces timezone-aware UTC date creation from time segments
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
packages/time-input/src/utils/shouldSetValue/shouldSetValue.ts |
Core logic determining when to update time input value based on segment state |
packages/time-input/src/utils/isSameUTCDayAndTime/isSameUTCDayAndTime.ts |
Utility for comparing two dates for equality in UTC |
packages/time-input/src/utils/isEverySegmentValueExplicit/isEverySegmentValueExplicit.ts |
Validates that all time segments have unambiguous values |
packages/time-input/src/utils/isEverySegmentValid/isEverySegmentValid.ts |
Checks if all time segments are within valid ranges |
packages/time-input/src/utils/isEverySegmentFilled/isEverySegmentFilled.ts |
Verifies that all time segments contain values |
packages/time-input/src/utils/getNewUTCDateFromSegments/getNewUTCDateFromSegments.ts |
Creates UTC date from time segments with timezone support |
packages/time-input/src/utils/getFormattedTimeSegmentsFromDate/getFormattedTimeSegmentsFromDate.ts |
Extracts and formats time segments from a date object |
packages/time-input/src/utils/getFormattedTimeSegments/getFormattedTimeSegments.ts |
Pads time segments to 2-digit format |
packages/time-input/src/utils/findUnitOptionByDayPeriod/findUnitOptionByDayPeriod.ts |
Locates the AM/PM unit option matching a day period |
packages/time-input/src/utils/doesSomeSegmentExist/doesSomeSegmentExist.ts |
Checks if any time segment has a value |
packages/time-input/src/utils/convert12hTo24h/convert12hTo24h.ts |
Converts 12-hour format to 24-hour format |
packages/date-utils/src/newUTCFromTimeZone/newUTCFromTimeZone.ts |
Creates UTC date from local time in specified timezone |
packages/time-input/src/utils/index.ts |
Exports all new time input utility functions |
packages/date-utils/src/index.ts |
Exports new UTC timezone conversion utility |
| Test files (*.spec.ts) | Comprehensive test coverage for all new utilities |
| ); | ||
| }); | ||
|
|
||
| test('returns false is all segments are empty', () => { |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'is' to 'if' in test description.
| test('returns false is all segments are empty', () => { | |
| test('returns false if all segments are empty', () => { |
| ); | ||
| }); | ||
|
|
||
| test('returns true if at all segments are filled', () => { |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The phrase 'at all segments' should be 'all segments' to be grammatically correct.
| test('returns true if at all segments are filled', () => { | |
| test('returns true if all segments are filled', () => { |
|
Size Change: +173 B (+0.01%) Total Size: 1.82 MB
ℹ️ View Unchanged
|
…orrect input validation
|
Coverage after merging LG-5532/segments-state-utils into LG-5532/segments-display-values will be
Coverage Report for Changed Files
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
✍️ Proposed changes
🎟 Jira ticket: Name of ticket
This PR introduces utility functions for managing time input segment state, including validation, formatting, and conversion between 12-hour and 24-hour formats. The implementation handles timezone conversions, segment validation, and provides comprehensive test coverage.
This PR is the third PR in a chain of PRs
🧪 How to test changes