public function nthPreviousPeriod($n = 0)
    {
        $n = max(0, $n);

        // determine the interval string
        $interval = $this->interval($this->granularity());

        // calculate the start of the current period
        $start = $this->startOfDay(strtotime('this '.$interval));

        // go back N periods
        $i = $n;
        while ($i > 0) {
            $start = $this->startOfDay(strtotime('-1 '.$interval, $start));
            --$i;
        }

        // the end will be the start + 1 period - 1 second
        $end = $this->endOfDay(strtotime('+1 '.$interval, $start) - 1);

        return [
            'start' => $start,
            'end' => $end, ];
    }