Ah, gotcha. You'll probably want to switch the sign in my return statement, then.
The reset is that now.getMinutes() and now.getHours() will return 0 at midnight, and any past(PERIOD, 0) call will have an empty data set (I should confirm this, it could have a single data point if there's a value at that millisecond), and the sum of an empty data set is 0, so it'll be 0 - 0 = 0