Skip to content
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

Incorrect time is shown for 12:00 PM when using 12 hour time format #27

Closed
ArizArmeidi opened this issue Oct 15, 2024 · 2 comments · Fixed by #28
Closed

Incorrect time is shown for 12:00 PM when using 12 hour time format #27

ArizArmeidi opened this issue Oct 15, 2024 · 2 comments · Fixed by #28

Comments

@ArizArmeidi
Copy link

image
When using the 12 hour time format the time text is showing 00:00 PM which is incorrect instead it should show 12:00 PM
image

after looking at the code I noticed the problem was caused by the date time extension specifically on the hourDisplay12 getter that is written like this

 String get hourDisplay12 =>
      "${(hour % 12).toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')} ${hour >= 12 ? 'PM' : 'AM'}";

Which is causing the 12 to be 0, I suggest you can modify the code to this so that it will display the time as expected

 String get hourDisplay12 {
    if (hour == 12) {
      return "${(hour).toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')} ${hour >= 12 ? 'PM' : 'AM'}";
    }
    return "${(hour % 12).toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')} ${hour >= 12 ? 'PM' : 'AM'}";
  }

image

@samderlust
Copy link
Owner

Hi @ArizArmeidi,
Thanks so much for finding the issue. I'll release a patch soon

@samderlust samderlust linked a pull request Oct 15, 2024 that will close this issue
@ArizArmeidi
Copy link
Author

Thanks for the quick response 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants