Use current date for input_datetime time rendering (#754)

* Use current date for input_datetime time rendering

Chrome has a bug where it fails to render times correctly using
toLocaleTimeString for certain dates in the past with non-normal
daylight saving rules. For the UK and New Zealand, this includes
1970-01-01. Instead of using this as the date when rendering the time
for a time only input_datetime, use the current date.

* Add comment

* Lint
This commit is contained in:
Nigel Rook 2018-01-02 13:02:26 +00:00 committed by Paulus Schoutsen
parent 27d343b488
commit 1d13126bb5

View File

@ -27,8 +27,11 @@ export default function computeStateDisplay(localize, stateObj, language) {
);
stateObj._stateDisplay = formatDate(date, language);
} else if (!stateObj.attributes.has_date) {
const now = new Date();
date = new Date(
1970, 0, 1,
// Due to bugs.chromium.org/p/chromium/issues/detail?id=797548
// don't use artificial 1970 year.
now.getFullYear(), now.getMonth(), now.getDay(),
stateObj.attributes.hour,
stateObj.attributes.minute
);