You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
Current behavior:
If you select the year 0001 in a input[date] field, the model values updates to the value 1901. https://codepen.io/anon/pen/KRzwXX
Expected / new behavior:
The model value should be set to the correct year 0001.
Minimal reproduction of the problem with instructions:
See codepen testcase https://codepen.io/anon/pen/KRzwXX
Insert the date '0001-01-01' and you can see the wrong model value.
AngularJS version: 1.6.9 / 1.7.0-rc.0
Browser: [all]
Also happens if the browser doesn't support input[date] fields. If the text '0001-01-01' is inserted, the model values is set to '1901-01-01'
The text was updated successfully, but these errors were encountered:
Interesting that nobody has noticed all these years 😁
This happens for all year values less than 100, because we callnew Date(1, ...) and according to MDN:
Values from 0 to 99 map to the years 1900 to 1999.
[...]
In order to create dates between the years 0 and 99 the Date.prototype.setFullYear() method should be used.
gkalpak
added a commit
to gkalpak/angular.js
that referenced
this issue
Apr 24, 2018
When parsing a date string value, AngularJS uses `new Date(year, ...)`
to create a Date object and assign it to the model. In the constructor,
2-digit years map to 1900-1999, so the created Date object has the wrong
value for year.
This commit fixes it, by explicitly using `setFullYear()` to set the
year to the correct value, when necessary.
Fixesangular#16537
When parsing a date string value, AngularJS uses `new Date(year, ...)`
to create a Date object and assign it to the model. In the constructor,
2-digit years map to 1900-1999, so the created Date object has the wrong
value for year.
This commit fixes it, by explicitly using `setFullYear()` to set the
year to the correct value, when necessary.
Fixes#16537Closes#16539
I'm submitting a ...
Current behavior:
If you select the year 0001 in a input[date] field, the model values updates to the value 1901.
https://codepen.io/anon/pen/KRzwXX
Expected / new behavior:
The model value should be set to the correct year 0001.
Minimal reproduction of the problem with instructions:
See codepen testcase https://codepen.io/anon/pen/KRzwXX
Insert the date '0001-01-01' and you can see the wrong model value.
AngularJS version: 1.6.9 / 1.7.0-rc.0
Browser: [all]
Also happens if the browser doesn't support input[date] fields. If the text '0001-01-01' is inserted, the model values is set to '1901-01-01'
The text was updated successfully, but these errors were encountered: