Skip to content

Conversation

@sean-perkins
Copy link
Contributor

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Locales that have the hour cycle in 24 hour format, will not respect the max time range specified. This means if you set the max to 20:40, they are still able to select 21, 22, 23 for hour values.

Issue Number: #24588

What is the new behavior?

Does this introduce a breaking change?

  • Yes
  • No

Other information

@sean-perkins sean-perkins requested a review from a team January 20, 2022 16:27
@github-actions github-actions bot added the package: core @ionic/core package label Jan 20, 2022
*/
if (maxParts.hour !== undefined) {
processedHours = processedHours.filter(hour => {
const convertedHour = refParts.ampm === 'pm' ? (hour + 12) % 24 : hour;
Copy link
Contributor

@liamdebeasi liamdebeasi Jan 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this change works? If you are using 24 hour time, refParts.ampm should be undefined, which means convertedHour would be hour.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workingParts (used as refParts in that util function) has ampm defined. Likely as a result of when we call processValue on initialization of the datetime component:

...
this.workingParts = {
  ...
  ampm: hour >= 12 ? 'pm' : 'am'
}

Where as the hour cycle only takes into consideration the locale or if the developer has hard-set the hour cycle.

So this case exists when the developer hasn't specified the hour cycle manually, but the locale requires it.

Copy link
Contributor

@liamdebeasi liamdebeasi Jan 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that makes sense for now. I'll confirm we aren't using that interface for any partial date object comparisons.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sean-perkins sean-perkins merged commit 5925e76 into main Jan 20, 2022
@sean-perkins sean-perkins deleted the FW-602 branch January 20, 2022 17:47
@Agular
Copy link

Agular commented Jan 31, 2022

Applies the same logic for restricting minutes used here fix(datetime): time picker format with hourCycle h23 #24476

Was this implemented? Since I am using ionic 6.0.4 and the minutes are not updated when choosing a time with the hour less than the hour of the max time. This was recently fixed for min value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants