Is a browser required to detect a custom time zone for entering date and time?

I installed Opera because it is currently the only browser with HTML5 datetime calendar functionality. There are two types of datetime input: one is datetime-local , where timezone information is omitted; another << 20>, where time zone information is added.

From what I observe in Opera, the time zone is fixed in UTC instead of following the user time zone for entering datetime . This seems inconsistent, because the user usually does not know what UTC time is, not to mention calculating the correct UTC time based on his own time zone.

Does W3C require UTC to be the default time zone for entering datetime , or does the Opera browser do the right thing by setting the time zone as UTC?

With further research, this is what I find:

whatwg seems to offer a way back:

  • datetime (specific year, month, day, time)
  • datetime-local (specific year, month, day, time, time zone)

Mozilla's documentation says the following:

  • datetime: HTML5 A control to enter the date and time (hour, minute, second, and split second) according to the UTC time zone.

W3C offers the following:

  • User agents should not allow the user to set the value to a non-empty string that is not a valid global UTC date and time string, although user agents can allow the user to set and view the time in a different time zone and silently translate the time to and from UTC in value. If the user agent provides a user interface for selecting a global date and time, then the value must be set to a valid global date and time string, expressed in UTC, representing the user choice.

  • The format shown to the user is independent of the format used to submit the form. The browser is recommended to use user interfaces that represent dates and times in accordance with the conventions of the user's preferred locale.

It seems to me that W3C allows you to enter datetime in a local format, but requires that the final value represented by the form be expressed in UTC.

+4
source share
1 answer

The only question you asked:

Does W3C require UTC to be the default time zone for entering datetime data, or does the Opera browser do the right thing by setting the time zone as UTC?

But as you pointed out:

user agents can allow the user to set and view the time in a different time zone

So, the answer to your question is that W3C does not require UTC for input, but allows it, so Opera will do everything right.

These ambiguous specifications are pretty dumb. In fact, they are quite counterproductive. I don’t understand why they are even worried if they are actually going to determine the required behavior.

+1
source

All Articles