Fix time comparison function

It needs to be able to deal with space separated date/time as well.
This caused changes to the From time to sometimes not trigger a redraw.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Make sure daily stats are always zero based

Sometimes Flotchart decides to make one of the series not 0 based - I can't
quite understand why, but this fixes the issue.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Make sure the first data point is taken into account

Without this we'd ignore the beginning of the series.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix silly typo that causes us to miss the first entry on energy graph

I so dislike that node.js doesn't throw an error on stuff like this.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Improved estimates for energy used for the stats page

There are different error cases that all contribute to incorrect data. The
worst one is if the streaming service is down (or you are out of range) while
you are driving. Even when manually filling in some data points (to at least
not have all the energy used be accounted as Vampire drain), the old algorithm
would get things relentlessly and obviously wrong.

This does several things to improve the situation:

- sort the data returned from the streaming algorithm
  (this one pains me, but if you are forced to add entries to the database
  to compensate for lacking streaming data, the streaming data is no longer
  in chronologic order and the algorithm flat out fails)
- calculate the used energy two different ways:
-- once by the old "discrete integration over time" using the streaming data
-- once by observing the charge state while driving (as that gives us range in
   1/10 mile resolution) and converting it to power used
- for unexplained reasons sometimes charge state data is missing, so we need
  to do both calculations and figure out which one to trust.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Merge pull request #51 from dirkhh/fixes

Fixes