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:
Anders Melchiorsen 2017-04-26 04:56:23 +02:00 committed by Paulus Schoutsen
parent 1ef050e76d
commit 5357fc25d8
2 changed files with 4 additions and 4 deletions

View File

@ -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];
},
},

View File

@ -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];
},
},