mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-13 12:26:35 +00:00
Rewrite _currentDate to work in all time zones (#266)
* Rewrite _currentDate to work in all time zones The method toISOString() returns a timestamp in UTC. Thus, midnight in the CET timezone (UTC+1) was converted into yesterday@2300 and then that date was used as the current date. This made the logbook and history start with yesterday's data, at least for locations east of UTC. The new version avoids this by using methods that work in local time. * Remove an embarrassing amount of lint * Rewrite to be more concise Proposed by @armills.
This commit is contained in:
parent
1ef050e76d
commit
5357fc25d8
@ -121,8 +121,8 @@ Polymer({
|
||||
type: String,
|
||||
value: function () {
|
||||
var value = new Date();
|
||||
value.setHours(0, 0, 0);
|
||||
return value.toISOString().split('T')[0];
|
||||
var today = new Date(Date.UTC(value.getFullYear(), value.getMonth(), value.getDate()));
|
||||
return today.toISOString().split('T')[0];
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -98,8 +98,8 @@ Polymer({
|
||||
type: String,
|
||||
value: function () {
|
||||
var value = new Date();
|
||||
value.setHours(0, 0, 0);
|
||||
return value.toISOString().split('T')[0];
|
||||
var today = new Date(Date.UTC(value.getFullYear(), value.getMonth(), value.getDate()));
|
||||
return today.toISOString().split('T')[0];
|
||||
},
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user