ermouth / jQuery.my

jQuery.my is a plugin that reactively binds form controls with js data structures.
https://jquerymy.com
1.51k stars 114 forks source link

Please support datetime and datetime-local type for input #26

Open libook opened 8 years ago

libook commented 8 years ago

Please support datetime and datetime-local type for input

ermouth commented 8 years ago

Well, this support is reasonable in theory, but in practice... how do you see it?

input[type=datetime] is not supported by browsers, so how can I test it? Also this type of INPUT controls removed from HTML5 standard.

Although input[type=datetime-local] is supported by Opera and Chrome, and is in HTML 5.1 draft, implementation is awful.

For example, go here http://www.w3schools.com/html/tryit.asp?filename=tryhtml_input_datetime-local, set date and time, select control in devtool Elements view, and then check actual value of the control using $0.valueAsNumber.

You will be surprised, that control actually does not take in account your locale and sets value in GMT.

Any suggestions?

libook commented 8 years ago

Sorry for late response.


The type 'datetime' has been removed from the HTML standard, so never mind it.

Although the type 'datetime-local' is new, it works fine on my browsers, even though on windows. So maybe it is the time for adding it?


You will be surprised, that control actually does not take in account your locale and sets value in GMT.

I didn't understand this paragraph.


The input element with a type attribute whose value is "datetime-local" represents a control for setting the element’s value to a string representing a local date and time (with no timezone information).

Source

According to my understanding, the type 'datetime-local' means 'Nothing to do with time zone'. So the input element with 'datetime-local' type will not do any processing with time zone. In other words, If I input the time which is from my watch, the value of the input will be the same with my inputting.

For example, if I input '2016/01/02 05:22 pm', the 'valueAsNumber' will be 1451755320000 and the 'value' will be "2016-01-02T17:22". The timestamp 1451755320000 is just 2016-01-02 17:22 with no time zone information.

If I want to process datetime with time zone, I must do time zone converting between the value of input element and my Date object.

Apologize if I misunderstand your comment.