public static function getDateXPeriodsAgo($subXPeriods, $date = false, $period = false)
    {
        if ($date === false) {
            $date = Common::getRequestVar('date');
        }

        if ($period === false) {
            $period = Common::getRequestVar('period');
        }

        if (365 == $subXPeriods && 'day' == $period && Date::today()->isLeapYear()) {
            $subXPeriods = 366;
        }

        // can't get the last date for range periods & dates that use lastN/previousN
        $strLastDate = false;
        $lastPeriod  = false;
        if ($period != 'range' && !preg_match('/(last|previous)([0-9]*)/', $date, $regs)) {
            if (strpos($date, ',')) {
                // date in the form of 2011-01-01,2011-02-02

                $rangePeriod = new Range($period, $date);

                $lastStartDate = $rangePeriod->getDateStart()->subPeriod($subXPeriods, $period);
                $lastEndDate   = $rangePeriod->getDateEnd()->subPeriod($subXPeriods, $period);

                $strLastDate = "$lastStartDate,$lastEndDate";
            } else {
                $lastPeriod  = Date::factory($date)->subPeriod($subXPeriods, $period);
                $strLastDate = $lastPeriod->toString();
            }
        }

        return array($strLastDate, $lastPeriod);
    }