Hi,
I'm building a dashboard with a DateRangeFilter in it. I also have two
buttons, labeled Today and Yesterday that set the range of the
DateRangeFilter with code like this:
var today = new Date();
today.setHours(0, 0, 0, 0);
const dayLength = 24 * 60 * 60 * 1000;
switch (buttonSelection)
{
case 'today' :
dateRangeSlider.setState({lowValue : today, highValue : new
Date(today.getTime() + dayLength)});
break;
case 'yesterday' :
var yesterday = new Date(today.getTime() - dayLength);
dateRangeSlider.setState({lowValue : yesterday, highValue :
today});
break;
}
dateRangeSlider.draw();
But when it runs, the range ends up including two days. E.g. if it's 9/6
and I click 'Today', the range shows 9/5 through 9/7; if I click
'Yesterday', the range becomes 9/4 through 9/6.
If I step through the code, after the call to setState, the lowValue is
9/6/2014 00:00:00 and the highValue is 9/7/2014 00:00:00 - so far, so good.
But after the call to draw(), lowValue is 9/5/2014 01:00:00 and highValue
is 9/7/2014 01:00:00. I can understand that some of this might be Daylight
Saving Time related: midnight becoming 1 AM. But why would 9/6/2014 00:00
change to 9/5/2014 01:00?
Plus, this isn't quite what I want. Since the high and low values are
inclusive, for Yesterday I don't want 9/5 00:00 through 9/6 00:00: I want
9/5 00:00 through 9/5 23:59:59. But if I set that, DateRangeFilter changes
9/5 23:59:59 to 9/6 01:00:00.
Am I doing something wrong, or are these bugs in DateRangeFilter? If the
latter, is there a workaround?
Thanks,
Bob
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.