This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 20880 - When a max attribute is specified, should that replace the base step of 1970-01-01 or should it only be replaced when a min value is specified? In this example, the latest Chrome does not change the [...]
Summary: When a max attribute is specified, should that replace the base step of 1970-...
Status: RESOLVED WORKSFORME
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-05 18:19 UTC by contributor
Modified: 2013-03-26 00:18 UTC (History)
3 users (show)

See Also:


Attachments

Description contributor 2013-02-05 18:19:28 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html
Multipage: http://www.whatwg.org/C#date-state-(type=date)
Complete: http://www.whatwg.org/c#date-state-(type=date)

Comment:
When a max attribute is specified, should that replace the base step of
1970-01-01 or should it only be replaced when a min value is specified?  In
this example, the latest Chrome does not change the default base whereas Opera
does: <input type="date" step="2" max="1970-01-02">

Posted from: 64.66.99.129
User agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17
Comment 1 Benjamin Solum 2013-02-06 13:51:04 UTC
Hello All,

I was messing around with the new HTML5 input elements, in particular the date element. I constructed the element like so:

<input type="date" step="2" max="1970-01-04">

The default base for date elements is the epoch or 1970-01-01 in this case.  However, most browsers will change the default base either to the max or the min element if they are valid date strings.

This is where it gets tricky, because the spec doesn't specify when max or min should be used, at least that I can find.

In the latest version of Opera, the above field could have a valid value of "1970-01-02", because Opera changes the default step to 1970-01-04 and 1970-01-02 is -2 days away, which is an even modulo of the step (-2 % 2 == 0). In Chrome it is **NOT** a valid date, because the default base remains "1970-01-01" and that leaves us +3 days away, which is an odd modulo of the step (3 % 2 == 1).

Which browser is in the right?  I'm leaning towards Opera.  It seems to be that the max attribute should be used unless a min attribute is provided, in which that should be used as the default step.  If neither are present, use 1970-01-01.

Am I understanding this correctly?
Comment 2 Ian 'Hixie' Hickson 2013-02-06 21:53:01 UTC
The step base is defined here:
   http://whatwg.org/html/#concept-input-min-zero

That algorithm doesn't mention 'max' anywhere. It defines that it uses 'min' and 'value', defaulting to 0 (except for type=week).

Applying that algorithm to the example in comment 1, you get a step base of 0 (which is equivalent to 1970-01-01).

So Opera is wrong here.
Comment 3 Ian 'Hixie' Hickson 2013-03-26 00:18:07 UTC
Please re-open the bug if you disagree with my line of reasoning.