GithubHelp home page GithubHelp logo

Comments (10)

linear avatar linear commented on August 15, 2024

ENG-958 [BUG] - Time Input wrong HourCycle

from nextui.

wingkwong avatar wingkwong commented on August 15, 2024

Can you share the code same as your screenshot? The example looks fine on my side.

from nextui.

timwirt avatar timwirt commented on August 15, 2024

image
image
image
image
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?

from nextui.

wingkwong avatar wingkwong commented on August 15, 2024

but i didn't see you specified hourCycle in your time input.

from nextui.

timwirt avatar timwirt commented on August 15, 2024

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.

from nextui.

wingkwong avatar wingkwong commented on August 15, 2024

@timwirt I got it now. can you help test two things -

  1. try to set hourCycle to both 12 and 24, and share the result here.
  2. try not to set hourCycle and test with other browsers.

from nextui.

timwirt avatar timwirt commented on August 15, 2024

Ok,

  1. manually setting the hourCycle works (but i think it is still not correct that is shows 11:00 it should be 09:00)
    image
    (left one is 24h and right is 12h)
  2. the behaviour is the same on edge and responsively app

from nextui.

wingkwong avatar wingkwong commented on August 15, 2024
  • for the left one, 11 looks fine to me since your input is 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 right one, please apply 24h and share the result.

from nextui.

timwirt avatar timwirt commented on August 15, 2024
  • for the left one, 11 looks fine to me since your input is 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.

Ok, thank you.

image
Right also works.

from nextui.

timwirt avatar timwirt commented on August 15, 2024

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. 😁

from nextui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.