/**
  * Get a list of intervals for a given period
  * @param string $step Interval descriptor as defined in BsDiagram
  * @param string $offset Date string
  * @param string $limit Date string
  * @param string $modLabel Date format item, e.g. "M" for "Jan, Feb"
  * @return Interval
  */
 public static function getIntervals($step = "W", $offset = '05/01/2007', $limit = '01/31/2009', $modLabel = false)
 {
     $intervals = array();
     $starttime = strtotime($offset);
     $endtime = strtotime($limit);
     $interval = new Interval();
     $interval->setStartTS($starttime);
     $old = idate($step, $starttime);
     if ($modLabel) {
         $interval->setLabel(date($modLabel, $starttime));
     } else {
         $interval->setLabel($old);
     }
     $oldts = $starttime;
     for ($ts = $starttime; $ts <= $endtime; $ts += 86400) {
         $oldts = $ts - 1;
         $cur = idate($step, $ts);
         if ($old != $cur) {
             $interval->setEndTS($oldts);
             $intervals[] = $interval;
             $interval = new Interval();
             $interval->setStartTS($ts);
             if ($modLabel) {
                 $interval->setLabel(date($modLabel, $ts));
             } else {
                 $interval->setLabel($cur);
             }
             //echo "<br/>-----------------------";
         }
         $old = $cur;
         //echo "<br/>".$oldts." :: ".date("d.m.YHis", $oldts-1);
     }
     $oldts = $oldts + 86400;
     $interval->setEndTS($oldts);
     $intervals[] = $interval;
     //var_dump($intervals);
     return $intervals;
 }