Open timwirt opened 1 month ago
Can you share the code same as your screenshot? The example looks fine on my side.
As you can see gmt+2 is right (Europe/Berlin) but the hour cycle should be 24 hours and the times should be 09 and 17. Am I missing something obvious?
but i didn't see you specified hourCycle
in your time input.
This is from the documentation: By default, TimeInput displays times in either 12 or 24 hour hour format depending on the user's locale. However, this can be overridden using the hourCycle prop if needed for a specific usecase. This example forces TimeInput to use 24-hour time, regardless of the locale.
So for me it should automatically be 24 hours instead of 12 hours. It should adapt to the user's location.
@timwirt I got it now. can you help test two things -
hourCycle
to both 12
and 24
, and share the result here. hourCycle
and test with other browsers.Ok,
2024-04-08T09:00:00Z
. Z
means UTC+0
so if you are in GMT+2
(p.s. there is no difference between UTC and GMT), so that would be 9 + 2 = 11
.
- for the left one, 11 looks fine to me since your input is
2024-04-08T09:00:00Z
.Z
meansUTC+0
so if you are inGMT+2
(p.s. there is no difference between UTC and GMT), so that would be9 + 2 = 11
.
Ok, thank you.
Right also works.
Ok with help of this Workaround from stackoverflow i can detect the hour cycle like this
const hourCycle = new Intl.DateTimeFormat(undefined, {
hour: "numeric",
})
.format(new Date())
.match(/AM/)
? 12
: 24;
and now i just add to hourCycle={hourCycle}
to the time input. 😁
NextUI Version
2.4.1
Describe the bug
When using the Time Input it should automatically change the Hour Cycle for the right Time Zone. The examples from the documentation also dont work for me.
Your Example Website or App
No response
Steps to Reproduce the Bug or Issue
Expected behavior
E.g if i am in germany with the timezone gmt+2 (what is recognized correctly) the hourcycle should be 24 hours. The documentation says that this actually automatically selects the right one
Screenshots or Videos
Operating System Version
System: OS: win32 CPU: x64 Binaries: Node: v20.5.1
Browser
Chrome