+ function daystart(date) {
+ date.setMilliseconds(0);
+ date.setSeconds(0);
+ date.setMinutes(0);
+ date.setHours(0);
+ return date;
+ }
+
+ function prevweek() {
+ var tdy = daystart(new Date());
+ var dow = tdy.getDay();
+ var wstart, wend;
+
+ wstart = new Date(1*tdy - 86400000 * (dow + 7));
+ wend = new Date(1*wstart + 86400000 * 7);
+ sendquery(wstart.toISOString(), wend.toISOString());
+ }
+
+ function thisweek() {
+ var tdy = daystart(new Date());
+ var dow = tdy.getDay();
+ var wstart, wend;
+
+ wstart = new Date(1*tdy - 86400000 * dow);
+ wend = new Date(1*wstart + 86400000 * 7);
+ sendquery(wstart.toISOString(), wend.toISOString());
+ }
+
+ function beforeyesterday() {
+ var tdy = daystart(new Date());
+ var ytd = new Date(1*tdy - 86400000);
+ var byd = new Date(1*ytd - 86400000);
+ sendquery(byd.toISOString(), ytd.toISOString());
+ }
+
+ function yesterday() {
+ var tdy = daystart(new Date());
+ var ytd = new Date(1*tdy - 86400000);
+ sendquery(ytd.toISOString(), tdy.toISOString());
+ }
+
+ function today() {
+ var tdy = daystart(new Date());
+ var tmr = new Date(1*tdy + 86400000);
+ sendquery(tdy.toISOString(), tmr.toISOString());
+ }
+