public function __construct(Date $base, $weekStart = Timestamp::WEEKDAY_MONDAY)
 {
     $firstDayOfMonth = Date::create($base->getYear() . '-' . $base->getMonth() . '-01');
     $lastDayOfMonth = Date::create($base->getYear() . '-' . $base->getMonth() . '-' . date('t', $base->toStamp()));
     $start = $firstDayOfMonth->getFirstDayOfWeek($weekStart);
     $end = $lastDayOfMonth->getLastDayOfWeek($weekStart);
     $this->monthRange = DateRange::create()->lazySet($firstDayOfMonth, $lastDayOfMonth);
     $this->fullRange = DateRange::create()->lazySet($start, $end);
     $rawDays = $this->fullRange->split();
     $this->fullLength = 0;
     foreach ($rawDays as $rawDay) {
         $day = CalendarDay::create($rawDay->toStamp());
         if ($this->monthRange->contains($day)) {
             $day->setOutside(false);
         } else {
             $day->setOutside(true);
         }
         $this->days[$day->toDate()] = $day;
         $weekNumber = floor($this->fullLength / 7);
         if (!isset($this->weeks[$weekNumber])) {
             $this->weeks[$weekNumber] = CalendarWeek::create();
         }
         $this->weeks[$weekNumber]->addDay($day);
         ++$this->fullLength;
     }
     ++$this->fullLength;
 }
示例#2
0
 /**
  * A method that can be inherited and used by children classes to get the
  * required date span of a statistics page.
  *
  * @param object $oCaller      The calling object. Expected to have the
  *                             the following class variables:
  *                                  $oCaller->aPlugins    - An array of statistics fields plugins
  *                                  $oCaller->oStartDate  - Will be set by method
  *                                  $oCaller->spanDays    - Will be set by method
  *                                  $oCaller->spanWeeks   - Will be set by method
  *                                  $oCaller->spanMonths  - Will be set by method
  * @param array  $aParams      An array of query parameters for
  *                             {@link Admin_DA::fromCache()}.
  */
 function getSpan(&$oCaller, $aParams)
 {
     $oStartDate = new Date(date('Y-m-d'));
     $oStartDate->setHour(0);
     $oStartDate->setMinute(0);
     $oStartDate->setSecond(0);
     // Check span using all plugins
     foreach ($oCaller->aPlugins as $oPlugin) {
         $aPluginParams = call_user_func(array($oPlugin, 'getHistorySpanParams'));
         $aSpan = Admin_DA::fromCache('getHistorySpan', $aParams + $aPluginParams);
         if (!empty($aSpan['start_date'])) {
             $oDate = new Date($aSpan['start_date']);
             $oDate->setTZbyID('UTC');
             if ($oDate->before($oStartDate)) {
                 $oDate->convertTZ($oStartDate->tz);
                 $oStartDate = new Date($oDate);
             }
         }
     }
     $oStartDate->setHour(0);
     $oStartDate->setMinute(0);
     $oStartDate->setSecond(0);
     $oNow = new Date();
     $oSpan = new Date_Span(new Date($oStartDate), new Date($oNow->format('%Y-%m-%d')));
     // Store the span data required for stats display
     $oCaller->oStartDate = $oStartDate;
     $oCaller->spanDays = (int) ceil($oSpan->toDays());
     $oCaller->spanWeeks = (int) ceil($oCaller->spanDays / 7) + ($oCaller->spanDays % 7 ? 1 : 0);
     $oCaller->spanMonths = ($oNow->getYear() - $oStartDate->getYear()) * 12 + ($oNow->getMonth() - $oStartDate->getMonth()) + 1;
     // Set the caller's aDates span in the event that it's empty
     if (empty($oCaller->aDates)) {
         $oCaller->aDates['day_begin'] = $oStartDate->format('%Y-%m-%d');
         $oCaller->aDates['day_end'] = $oNow->format('%Y-%m-%d');
     }
 }
示例#3
0
文件: DateTest.php 项目: seytar/psx
 public function testDateOffset()
 {
     $date = new Date('2015-04-25+01:00');
     $this->assertEquals(2015, $date->getYear());
     $this->assertEquals(4, $date->getMonth());
     $this->assertEquals(25, $date->getDay());
     $this->assertEquals(3600, $date->getOffset());
     $this->assertInstanceOf('DateTimeZone', $date->getTimeZone());
     $this->assertEquals('2015-04-25+01:00', $date->toString());
 }
  function testSetByLocaleStringShort()
  {
    $date = new Date();

    $locale = new Locale('en');
    $date->setByLocaleString($locale, 'Thu 20 Jan 2005', '%a %d %b %Y');

    $this->assertEqual($date->getMonth(), 1);
    $this->assertEqual($date->getYear(), 2005);
    $this->assertEqual($date->getDay(), 20);
  }
示例#5
0
 /**
  * Adds a holiday to the driver's holidays
  *
  * @param string $internalName internal name - must not contain characters
  *                              that aren't allowed as variable-names
  * @param mixed  $date         date (timestamp | string | PEAR::Date object)
  * @param string $title        holiday title
  *
  * @access   protected
  * @return   void
  */
 function _addHoliday($internalName, $date, $title)
 {
     if (!is_a($date, 'Date')) {
         $date = new Date($date);
     }
     $this->_dates[$internalName] = $date;
     $this->_titles['C'][$internalName] = $title;
     $isodate = mktime(0, 0, 0, $date->getMonth(), $date->getDay(), $date->getYear());
     if (!isset($this->_holidays[$isodate])) {
         $this->_holidays[$isodate] = array();
     }
     array_push($this->_holidays[$isodate], $internalName);
     array_push($this->_internalNames, $internalName);
 }
示例#6
0
 private function datePicker(Date $dateObj)
 {
     $yStart = empty($this->yearStart) ? "-3" : $this->yearStart;
     $yEnd = empty($this->yearEnd) ? "+3" : $this->yearEnd;
     return $this->ascList("d", 1, 31, $dateObj->getDay()) . $this->ascList("m", 1, 12, $dateObj->getMonth()) . $this->ascList("y", $this->getEvaledYear($yStart), $this->getEvaledYear($yEnd), $dateObj->getYear());
 }
示例#7
0
 public function isEquals(Date $date)
 {
     return $this->year === $date->getYear() && $this->month === $date->getMonth() && $this->day === $date->getDay();
 }
示例#8
0
 /**
  * A method to get the number of operation intervals in a given
  * start & end date range must be valid OI start & end date range
  *
  * @static
  * @param object $oStartDate PEAR::Date object
  * @param object $oEndDate PEAR::Date object
  * @return integer number of operation intervals remaining
  */
 function getIntervalsRemaining($oStartDate, $oEndDate)
 {
     $operationIntervalSeconds = OX_OperationInterval::getOperationInterval() * 60;
     // Convert to UTC
     $oStartCopy = new Date($oStartDate);
     $oStartCopy->toUTC();
     $oEndCopy = new Date($oEndDate);
     $oEndCopy->toUTC();
     // Get timestamp of start date/time - in seconds
     $startDateSeconds = mktime($oStartCopy->getHour(), $oStartCopy->getMinute(), $oStartCopy->getSecond(), $oStartCopy->getMonth(), $oStartCopy->getDay(), $oStartCopy->getYear());
     // Get timestamp of end date/time - in seconds
     $endDateSeconds = mktime($oEndCopy->getHour(), $oEndCopy->getMinute(), $oEndCopy->getSecond(), $oEndCopy->getMonth(), $oEndCopy->getDay(), $oEndCopy->getYear());
     // calculate interval length in seconds
     $interval = $endDateSeconds - $startDateSeconds;
     // find number of operation intervals during interval
     return $interval <= 0 ? 0 : round($interval / $operationIntervalSeconds);
 }
function transferFinishedTransactions($account, $plannedTransaction)
{
    $now = new Date();
    $date = new Date($plannedTransaction->getBeginDate());
    $dayOfMonth = $date->getDay();
    //While we are before now and the end date of this transaction
    while (!$date->after($now) && !$date->after(is_null($tmp = $plannedTransaction->getEndDate()) ? new Date('9999-12-31') : $tmp)) {
        $account->addFinishedTransaction($plannedTransaction->getAmount(), $plannedTransaction->getTitle(), $plannedTransaction->getDescription(), new Date($date), $plannedTransaction->getTransactionPartner(), $plannedTransaction->getCategory(), $plannedTransaction->getOutsideCapital(), false, true);
        //do the date calculation
        switch ($plannedTransaction->getRepeatUnit()) {
            case 'day':
                $date->addSeconds($plannedTransaction->getRepeatFrequency() * 24 * 60 * 60);
                break;
            case 'week':
                $date->addSeconds($plannedTransaction->getRepeatFrequency() * 7 * 24 * 60 * 60);
                break;
            case 'month':
                //Set the month
                $date = new Date(Date_Calc::endOfMonthBySpan($plannedTransaction->getRepeatFrequency(), $date->getMonth(), $date->getYear(), '%Y-%m-%d'));
                //And count back as far as the last valid day of this month
                while ($date->getDay() > $dayOfMonth) {
                    $date->subtractSeconds(24 * 60 * 60);
                }
                break;
            case 'year':
                $newYear = $date->getYear() + $plannedTransaction->getRepeatFrequency();
                if ($dayOfMonth == 29 && $date->getMonth() == 2 && !Date_Calc::isLeapYear($newYear)) {
                    $date->setDay(28);
                } else {
                    $date->setDay($dayOfMonth);
                }
                $date->setYear($newYear);
                break;
            default:
                throw new BadgerException('Account', 'IllegalRepeatUnit', $plannedTransaction->getRepeatUnit());
                exit;
        }
    }
}
 /**
  * Checks if the given day is the current day
  *
  * @param mixed $stamp Any timestamp format recognized by Pear::Date
  *
  * @return boolean
  * @access protected
  */
 function isToday($stamp)
 {
     static $today = null;
     if (is_null($today)) {
         $today = new Date();
     }
     $date = Calendar_Engine_PearDate::stampCollection($stamp);
     return $date->day == $today->getDay() && $date->month == $today->getMonth() && $date->year == $today->getYear();
 }
示例#11
0
function get_prior_month($template, $userID, $connection)
{
    $calc = new Date_Calc();
    $beg_date = new Date();
    $end_date = new Date();
    $beg_date->addMonths(-1);
    // Get current month dates.
    $beg_date->setDayMonthYear(1, $beg_date->getMonth(), $beg_date->getYear());
    $end_date->setDayMonthYear($calc->getLastDayOfMonth($beg_date->getMonth(), $beg_date->getYear()), $beg_date->getMonth(), $beg_date->getYear());
    $query = "SELECT SUM(seconds) AS seconds, SUM(distance) AS distance, sbr_type FROM flmain WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userID . " AND plan_type='a' GROUP BY sbr_type";
    $result = @mysql_query($query, $connection);
    $template->setCurrentBlock("PRIORMONTH");
    $template->setVariable("MONTHNAME", $beg_date->format("%B %Y"));
    if (mysql_num_rows($result) > 0) {
        while ($row = mysql_fetch_array($result)) {
            switch ($row["sbr_type"]) {
                case 's':
                    $template->setVariable("SWIMDUR", round(convert_seconds_minutes($row["seconds"]), 2) . "min");
                    $template->setVariable("SWIMDIST", $row["distance"] . " yds");
                    break;
                case 'b':
                    $template->setVariable("BIKEDUR", round(convert_seconds_minutes($row["seconds"]), 2) . "  min");
                    $template->setVariable("BIKEDIST", $row["distance"] . "  mi");
                    break;
                case 'r':
                    $template->setVariable("RUNDUR", round(convert_seconds_minutes($row["seconds"]), 2) . " min");
                    $template->setVariable("RUNDIST", $row["distance"] . " mi");
                    break;
            }
        }
    }
    /* Get the strength minutes */
    $query = "SELECT SUM(seconds) AS seconds FROM flstrength WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userID . " AND plan_type='a'";
    $results = @mysql_query($query, $connection);
    if ($results) {
        while ($row = mysql_fetch_array($results)) {
            $template->setVariable("STRDUR", round(convert_seconds_minutes($row["seconds"]), 2) . " min");
        }
    }
    $template->parseCurrentBlock();
}
 /**
  * Returns a date in the format used by MS-DOS.
  *
  * @see     http://www.vsft.com/hal/dostime.htm
  * @param   util.Date date
  * @return  int
  */
 protected function dosDate(Date $date)
 {
     return (($date->getYear() - 1980 & 0x7f) << 4 | $date->getMonth() & 0xf) << 5 | $date->getDay() & 0x1f;
 }
示例#13
0
 /**
  * @covers Geissler\Converter\Model\Date::getMonth
  */
 public function testGetMonth()
 {
     $this->assertInstanceOf($this->class, $this->object->setMonth(10));
     $this->assertEquals(10, $this->object->getMonth());
 }
示例#14
0
function getTemplateArrayCalendar($o_minDay, $s_date, $period)
{
    // today
    $today = new Date(getDateFromTimestamp(time()));
    $tsToday = $today->getTimestamp();
    // date asked for statistics
    $dateAsked = new Date($s_date);
    // used for going througt the month
    $date = new Date($s_date);
    $month = $date->getMonth();
    $year = $date->getYear();
    $prefixDay = $year . "-" . $month . "-";
    $date->setDate($prefixDay . '01');
    $week = $date->getWeek();
    $day = 1;
    $ts = $date->getTimestamp();
    while ($date->getMonth() == $month) {
        // day exists in stats, isn't it too old or in the future ?
        if ($date->getTimestamp() >= $o_minDay->getTimestamp() && $date->getTimestamp() <= $tsToday) {
            $exists = 1;
        } else {
            $exists = 0;
        }
        // day selected for stats view ?
        if ($period == DB_ARCHIVES_PERIOD_DAY && $date->getDay() == $dateAsked->getDay() || $period == DB_ARCHIVES_PERIOD_WEEK && $date->getWeek() == $dateAsked->getWeek() || $period == DB_ARCHIVES_PERIOD_MONTH || $period == DB_ARCHIVES_PERIOD_YEAR) {
            $selected = 1;
        } else {
            $selected = 0;
        }
        $weekNo = $date->getWeek() - $week;
        if (defined('MONDAY_FIRST') && MONDAY_FIRST == 'no' && date("w", $ts) == 0) {
            $weekNo += 1;
        }
        $dayOfWeek = (int) (!defined('MONDAY_FIRST') || MONDAY_FIRST == 'yes' ? date("w", $ts) == 0 ? 6 : date("w", $ts) - 1 : date("w", $ts));
        $return[$weekNo][$dayOfWeek] = array('day' => substr($date->getDay(), 0, 1) === '0' ? substr($date->getDay(), 1, 2) : $date->getDay(), 'date' => $date->get(), 'exists' => $exists, 'selected' => $selected);
        $date->addDays(1);
        //these 2 lines useless? to check
        $ts = $date->getTimeStamp();
        $date->setTimestamp($ts);
    }
    foreach ($return as $key => $r) {
        $row =& $return[$key];
        for ($i = 0; $i < 7; $i++) {
            if (!isset($row[$i])) {
                $row[$i] = "-";
            }
        }
        ksort($row);
    }
    return $return;
}
示例#15
0
 /**
  * Actualiza los datos de la tarea duplicada.
  * @version 26-02-09
  * @author Ana Martín
  */
 protected function updateDuplicarTareaFromRequest()
 {
     $tarea = $this->getRequestParameter('tarea');
     $value = sfContext::getInstance()->getI18N()->getTimestampForCulture($tarea['fecha_inicio']['date'], $this->getUser()->getCulture());
     $mi_date = new Date($value);
     $mi_date->setHours(isset($tarea['fecha_inicio']['hour']) ? $tarea['fecha_inicio']['hour'] : 0);
     $mi_date->setMinutes(isset($tarea['fecha_inicio']['minute']) ? $tarea['fecha_inicio']['minute'] : 0);
     $this->nueva_tarea->setFechaInicio($mi_date->getTimestamp());
     if (isset($tarea['fecha_vencimiento'])) {
         $value = sfContext::getInstance()->getI18N()->getTimestampForCulture($tarea['fecha_vencimiento']['date'], $this->getUser()->getCulture());
         $mi_date = new Date($value);
         $mi_date->setHours(isset($tarea['fecha_vencimiento']['hour']) ? $tarea['fecha_vencimiento']['hour'] : 0);
         $mi_date->setMinutes(isset($tarea['fecha_vencimiento']['minute']) ? $tarea['fecha_vencimiento']['minute'] : 0);
         $this->nueva_tarea->setFechaVencimiento($mi_date->getTimestamp());
     } else {
         if (isset($tarea['duracion'])) {
             $duracion_minutos = $tarea['duracion'];
             $fecha_vencimiento = mktime($mi_date->getHours(), $mi_date->getMinutes() + $duracion_minutos, 0, $mi_date->getMonth(), $mi_date->getDay(), $mi_date->getYear());
             $this->nueva_tarea->setFechaVencimiento(date('Y-m-d H:i', $fecha_vencimiento));
         } else {
             $this->nueva_tarea->setFechaVencimiento($mi_date->getTimestamp());
         }
     }
     if (isset($tarea['id_usuario'])) {
         $this->nueva_tarea->setIdUsuario($tarea['id_usuario']);
     }
 }
示例#16
0
    showerror();
}
//See if we have an authenticated user, if so, setup the appropriate message.
if (isset($_SESSION["loggedinUserName"])) {
    $delAll = FALSE;
    $userID = getUserID($connection);
    $yearmoday = explode("-", $_SESSION["nav_month"]);
    // See if the users is trying to display a month other than the current month.
    if ($yearmoday != NULL) {
        $display_mo = new Date();
        $display_mo->setDayMonthYear($yearmoday[2], $yearmoday[1], $yearmoday[0]);
    } else {
        $display_mo = new Date();
    }
    //Set the date to the first day of the month.
    $display_mo->setDayMonthYear(1, $display_mo->getMonth(), $display_mo->getYear());
    // Get the previous day from the displayed month.
    $prevDay = $display_mo->getPrevDay();
    $prevDay->setDayMonthYear(1, $prevDay->getMonth(), $prevDay->getYear());
    // Get the next day in from the diplayed month.
    $display_mo->setDayMonthYear($display_mo->getDaysInMonth(), $display_mo->getMonth(), $display_mo->getYear());
    $nextDay = $display_mo->getNextDay();
    $template->setCurrentBlock("NAVIGATION");
    $template->setVariable("MONTH", "{$display_mo->getMonthName()} {$display_mo->getYear()}");
    $template->setVariable("PREVIOUS", $prevDay->format("%Y-%m-%d"));
    $template->setVariable("NEXT", $nextDay->format("%Y-%m-%d"));
    $template->setVariable("TYPE", $display);
    setSelectOption($display, $template);
    $template->parseCurrentBlock();
    $Month = new Calendar_Month_Weekdays($display_mo->getYear(), $display_mo->getMonth(), 1);
    $Month->build();
示例#17
0
 public static function dayDifference(Date $left, Date $right)
 {
     return gregoriantojd($right->getMonth(), $right->getDay(), $right->getYear()) - gregoriantojd($left->getMonth(), $left->getDay(), $left->getYear());
 }
 function getLastArchives($n, $boolOnlyGetPeriodNMinus = 0, $dateTextType = DATE_NORMAL, $o_site = false)
 {
     //var_dump($this->archive->date->get());
     $date = new Date($this->archive->date->get());
     //var_dump($date->get());
     if ($o_site) {
         $o_siteToUse = $o_site;
     } else {
         $o_siteToUse = $this->archive->site;
     }
     $toArchive = array();
     switch ($this->archive->periodType) {
         case DB_ARCHIVES_PERIOD_DAY:
             $ts = $date->getTimestamp() + 86400;
             while (sizeof($toArchive) < $n) {
                 $toArchive[] = getDateFromTimestamp($ts -= 86400);
             }
             $typeDateDisplay = 2;
             $typeDateDisplayGraph = 8;
             $typeDateDisplayGraphLongAxis = 13;
             // only take N - x, only for page views comparisons
             if ($boolOnlyGetPeriodNMinus === 1) {
                 $date0 = $toArchive[0];
                 $date1 = $toArchive[7];
                 $date2 = $toArchive[14];
                 unset($toArchive);
                 $toArchive[] = $date0;
                 $toArchive[] = $date1;
                 $toArchive[] = $date2;
                 $typeDateDisplay = 7;
                 //print("date1 $date1 date2 $date2 ");
             }
             break;
         case DB_ARCHIVES_PERIOD_WEEK:
             $ts = $date->getTimestamp();
             $ts += 86400 * 7;
             while (sizeof($toArchive) < $n) {
                 $toArchive[] = getDateFromTimestamp($ts -= 86400 * 7);
             }
             $typeDateDisplay = 6;
             $typeDateDisplayGraph = 6;
             $typeDateDisplayGraphLongAxis = 13;
             break;
         case DB_ARCHIVES_PERIOD_MONTH:
             $s_date1 = getDateFromTimestamp(mktime(23, 59, 59, $date->getMonth() - $n % 12, 15, $date->getYear() - floor($n / 12)));
             $s_date2 = $date->get();
             $toArchive = array_reverse(getDayOfMonthBetween($s_date1, $s_date2));
             $typeDateDisplay = 5;
             $typeDateDisplayGraph = 10;
             $typeDateDisplayGraphLongAxis = 10;
             break;
         case DB_ARCHIVES_PERIOD_YEAR:
             for ($i = 0; $i < $n; $i++) {
                 $a = $date->getYear() - $i;
                 $toArchive[] = $a . "-01-01";
             }
             $typeDateDisplay = 11;
             $typeDateDisplayGraph = 12;
             break;
     }
     //var_dump($this->archive->date->get());
     $return = array();
     foreach ($toArchive as $dateToArchive) {
         //print("boucle :");
         // if day, and IF current date asked is today, then take current archive
         if ($dateToArchive == $this->archive->date->get() && $this->archive->periodType === DB_ARCHIVES_PERIOD_DAY && $o_siteToUse->getId() === $this->archive->site->getId()) {
             $a = $this->archive;
             // erreur possible ici ?
         } else {
             $a = $this->getArchive($o_siteToUse, $dateToArchive, $this->archive->periodType);
         }
         if ($dateTextType == DATE_GRAPH) {
             $dateToDisplay = getDateDisplay($typeDateDisplayGraph, new Date($dateToArchive));
             $dateComputed = getDateDisplay($typeDateDisplayGraph, $a->date);
         } else {
             if ($dateTextType == DATE_NORMAL) {
                 $dateToDisplay = getDateDisplay($typeDateDisplay, new Date($dateToArchive));
                 $dateComputed = getDateDisplay($typeDateDisplay, $a->date);
             } else {
                 if ($dateTextType == DATE_GRAPH_LONG_AXIS) {
                     $dateToDisplay = getDateDisplay($typeDateDisplayGraphLongAxis, new Date($dateToArchive));
                     $dateComputed = getDateDisplay($typeDateDisplayGraphLongAxis, $a->date);
                 }
             }
         }
         if ($this->archive->periodType === DB_ARCHIVES_PERIOD_WEEK) {
             $firstDayOfWeek = new Date(getFirstDayOfWeek(new Date($dateToArchive)));
             $minDay = $o_siteToUse->getMinDay();
             if ($firstDayOfWeek->getTimestamp() >= $minDay->getTimestamp()) {
                 $dateToDisplay = getDateDisplay($typeDateDisplay, $firstDayOfWeek);
             }
         }
         if ($dateComputed == $dateToDisplay) {
             //				print("$dateToDisplay is correctly computed ($dateComputed)<br>");
             $return[$dateComputed] = $a;
         } else {
             //				print("$dateToDisplay is not correctly computed ($dateComputed) ==> empty archive<br>");
             $return[$dateToDisplay] = $this->getEmptyArchive($o_siteToUse, $dateToArchive, $this->archive->periodType);
         }
     }
     //print("\n\n");exit;
     return $return;
 }
 private function computeSubscriptionDays($p_publication, $p_subscriptionTime) {
     $startDate = new Date();
     if ($p_publication->getTimeUnit() == 'D') {
         return $p_subscriptionTime;
     } elseif ($p_publication->getTimeUnit() == 'W') {
         return 7 * $p_subscriptionTime;
     } elseif ($p_publication->getTimeUnit() == 'M') {
         $endDate = new Date();
         $months = $p_subscriptionTime + $endDate->getMonth();
         $years = (int)($months / 12);
         $months = $months % 12;
         $endDate->setYear($endDate->getYear() + $years);
         $endDate->setMonth($months);
     } elseif ($p_publication->getTimeUnit() == 'Y') {
         $endDate = new Date();
         $endDate->setYear($endDate->getYear() + $p_subscriptionTime);
     }
     $dateCalc = new Date_Calc();
     return $dateCalc->dateDiff($endDate->getDay(), $endDate->getMonth(),
     $endDate->getYear(), $startDate->getDay(), $startDate->getMonth(), $startDate->getYear());
 }
 public static function makeLastDayOfMonth(Date $date)
 {
     return Timestamp::create(mktime(0, 0, 0, $date->getMonth() + 1, 0, $date->getYear()));
 }
 private function previousOccurence($date, $start = null)
 {
     if (is_null($start)) {
         $start = $this->beginDate;
     }
     $dayOfMonth = $start->getDay();
     //do the date calculation
     switch ($this->repeatUnit) {
         case 'day':
             $date->subtractSeconds($this->repeatFrequency * 24 * 60 * 60);
             break;
         case 'week':
             $date->subtractSeconds($this->repeatFrequency * 7 * 24 * 60 * 60);
             break;
         case 'month':
             //Set the month
             $date = new Date(Date_Calc::endOfMonthBySpan(-$this->repeatFrequency, $date->getMonth(), $date->getYear(), '%Y-%m-%d'));
             //And count back as far as the last valid day of this month
             while ($date->getDay() > $dayOfMonth) {
                 $date->subtractSeconds(24 * 60 * 60);
             }
             break;
         case 'year':
             $newYear = $date->getYear() - $this->repeatFrequency;
             if ($dayOfMonth == 29 && $date->getMonth() == 2 && !Date_Calc::isLeapYear($newYear)) {
                 $date->setDay(28);
             } else {
                 $date->setDay($dayOfMonth);
             }
             $date->setYear($newYear);
             break;
         default:
             throw new BadgerException('Account', 'IllegalRepeatUnit', $this->repeatUnit);
             exit;
     }
     //switch
     return $date;
 }
 /**
  * Formats a 
  *
  * @param   util.Date d
  * @return  string
  */
 public function format(Date $d)
 {
     $out = '';
     foreach ($this->format as $token) {
         switch ($token) {
             case '%Y':
                 $out .= $d->getYear();
                 break;
             case '%m':
                 $out .= str_pad($d->getMonth(), 2, '0', STR_PAD_LEFT);
                 break;
             case '%d':
                 $out .= str_pad($d->getDay(), 2, '0', STR_PAD_LEFT);
                 break;
             case '%H':
                 $out .= str_pad($d->getHours(), 2, '0', STR_PAD_LEFT);
                 break;
             case '%M':
                 $out .= str_pad($d->getMinutes(), 2, '0', STR_PAD_LEFT);
                 break;
             case '%S':
                 $out .= str_pad($d->getSeconds(), 2, '0', STR_PAD_LEFT);
                 break;
             case '%p':
                 $h = $d->getHours();
                 $out .= $h >= 12 ? 'PM' : 'AM';
                 break;
             case '%I':
                 $out .= str_pad($d->getHours() % 12, 2, '0', STR_PAD_LEFT);
                 break;
             case '%z':
                 $out .= $d->getTimeZone()->getName();
                 break;
             case '%Z':
                 $out .= $d->getOffset();
                 break;
             case is_array($token):
                 $out .= $token[1][call_user_func(array($d, 'get' . $token[0])) - 1];
                 break;
             default:
                 $out .= $token;
         }
     }
     return $out;
 }
 /**
  * Expands the planned transactions.
  * 
  * All occurences of planned transactions between now and the targetFutureCalcDate will be inserted
  * in finishedTransactions. For distinction the planned transactions will have a 'p' as first character
  * in their id.
  * 
  * @throws BadgerException If an illegal repeat unit is used.
  */
 public function expandPlannedTransactions()
 {
     $now = new Date();
     $now->setHour(0);
     $now->setMinute(0);
     $now->setSecond(0);
     foreach ($this->plannedTransactions as $currentTransaction) {
         $date = new Date($currentTransaction->getBeginDate());
         $dayOfMonth = $date->getDay();
         //While we have not reached targetFutureCalcDate
         while ($this->targetFutureCalcDate->after($date) && !$date->after(is_null($tmp = $currentTransaction->getEndDate()) ? new Date('9999-12-31') : $tmp)) {
             $inRange = true;
             //Check if there is one or more valutaDate filter and apply them
             foreach ($this->filter as $currentFilter) {
                 if ($currentFilter['key'] == 'valutaDate') {
                     switch ($currentFilter['op']) {
                         case 'eq':
                             if (Date::compare($date, $currentFilter['val']) != 0) {
                                 $inRange = false;
                             }
                             break;
                         case 'lt':
                             if (Date::compare($date, $currentFilter['val']) >= 0) {
                                 $inRange = false;
                             }
                             break;
                         case 'le':
                             if (Date::compare($date, $currentFilter['val']) > 0) {
                                 $inRange = false;
                             }
                             break;
                         case 'gt':
                             if (Date::compare($date, $currentFilter['val']) <= 0) {
                                 $inRange = false;
                             }
                             break;
                         case 'ge':
                             if (Date::compare($date, $currentFilter['val']) < 0) {
                                 $inRange = false;
                             }
                             break;
                         case 'ne':
                             if (Date::compare($date, $currentFilter['val']) == 0) {
                                 $inRange = false;
                             }
                             break;
                         case 'bw':
                         case 'ew':
                         case 'ct':
                             if (strncasecmp($date->getFormatted(), $currentFilter['val']->getFormatted(), 9999) != 0) {
                                 $inRange = false;
                             }
                             break;
                     }
                     if (!$inRange) {
                         break;
                     }
                 }
             }
             if (!$date->before($now) && $inRange) {
                 $this->finishedTransactions[] = new FinishedTransaction($this->badgerDb, $this, 'p' . $currentTransaction->getId() . '_' . $date->getDate(), $currentTransaction->getTitle(), $currentTransaction->getAmount(), $currentTransaction->getDescription(), new Date($date), $currentTransaction->getTransactionPartner(), $currentTransaction->getCategory(), $currentTransaction->getOutsideCapital(), false, true, $currentTransaction, 'PlannedTransaction');
             }
             //do the date calculation
             switch ($currentTransaction->getRepeatUnit()) {
                 case 'day':
                     $date->addSeconds($currentTransaction->getRepeatFrequency() * 24 * 60 * 60);
                     break;
                 case 'week':
                     $date->addSeconds($currentTransaction->getRepeatFrequency() * 7 * 24 * 60 * 60);
                     break;
                 case 'month':
                     //Set the month
                     $date = new Date(Date_Calc::endOfMonthBySpan($currentTransaction->getRepeatFrequency(), $date->getMonth(), $date->getYear(), '%Y-%m-%d'));
                     //And count back as far as the last valid day of this month
                     while ($date->getDay() > $dayOfMonth) {
                         $date->subtractSeconds(24 * 60 * 60);
                     }
                     break;
                 case 'year':
                     $newYear = $date->getYear() + $currentTransaction->getRepeatFrequency();
                     if ($dayOfMonth == 29 && $date->getMonth() == 2 && !Date_Calc::isLeapYear($newYear)) {
                         $date->setDay(28);
                     } else {
                         $date->setDay($dayOfMonth);
                     }
                     $date->setYear($newYear);
                     break;
                 default:
                     throw new BadgerException('Account', 'IllegalRepeatUnit', $currentTransaction->getRepeatUnit());
                     exit;
             }
         }
     }
 }
示例#24
0
 static function getMoonTimes($date, $lat, $lng, $inUTC = null)
 {
     if ($inUTC === null) {
         $inUTC = false;
     }
     if ($inUTC) {
         $this1 = datetime__DateTime_DateTime_Impl_::utc(suncalc_SunCalc_0($date, $inUTC, $lat, $lng));
         $date = Date::fromTime(($this1 - 62135596800.0) * 1000);
         $date = new Date($date->getFullYear(), $date->getMonth(), $date->getDate(), 0, 0, 0);
     } else {
         $date = new Date($date->getFullYear(), $date->getMonth(), $date->getDate(), 0, 0, 0);
     }
     $hc = 0.133 * suncalc_SunCalc::$rad;
     $h0 = suncalc_SunCalc::getMoonPosition($date, $lat, $lng)->altitude - $hc;
     $h1 = null;
     $h2 = null;
     $rise = 0.0;
     $set = 0.0;
     $a = null;
     $b = null;
     $xe = null;
     $ye = 0.0;
     $d = null;
     $roots = null;
     $x1 = 0.0;
     $x2 = 0.0;
     $dx = null;
     $i = 1;
     while ($i <= 24) {
         $h1 = suncalc_SunCalc::getMoonPosition(suncalc_SunCalc::hoursLater($date, $i), $lat, $lng)->altitude - $hc;
         $h2 = suncalc_SunCalc::getMoonPosition(suncalc_SunCalc::hoursLater($date, $i + 1), $lat, $lng)->altitude - $hc;
         $a = ($h0 + $h2) / 2 - $h1;
         $b = ($h2 - $h0) / 2;
         $xe = -$b / (2 * $a);
         $ye = ($a * $xe + $b) * $xe + $h1;
         $d = $b * $b - 4 * $a * $h1;
         $roots = 0;
         if ($d >= 0) {
             $dx = Math::sqrt($d) / (Math::abs($a) * 2);
             $x1 = $xe - $dx;
             $x2 = $xe + $dx;
             if (Math::abs($x1) <= 1) {
                 $roots++;
             }
             if (Math::abs($x2) <= 1) {
                 $roots++;
             }
             if ($x1 < -1) {
                 $x1 = $x2;
             }
         }
         if ($roots === 1) {
             if ($h0 < 0) {
                 $rise = $i + $x1;
             } else {
                 $set = $i + $x1;
             }
         } else {
             if ($roots === 2) {
                 $rise = $i + ($ye < 0 ? $x2 : $x1);
                 $set = $i + ($ye < 0 ? $x1 : $x2);
             }
         }
         if (!_hx_equal($rise, 0) && !_hx_equal($set, 0)) {
             break;
         }
         $h0 = $h2;
         $i += 2;
     }
     $result = new haxe_ds_StringMap();
     if (!_hx_equal($rise, 0)) {
         $v = suncalc_SunCalc::hoursLater($date, $rise);
         $result->set("rise", $v);
         $v;
     }
     if (!_hx_equal($set, 0)) {
         $v1 = suncalc_SunCalc::hoursLater($date, $set);
         $result->set("set", $v1);
         $v1;
     }
     if (_hx_equal($rise, 0) && _hx_equal($set, 0)) {
         $result->set($ye > 0 ? "alwaysUp" : "alwaysDown", true);
         true;
     }
     return $result;
 }
示例#25
0
function create_history()
{
    global $wpdb;
    global $userdata;
    get_currentuserinfo();
    $yearmoday = explode("-", $_SESSION["nav_month"]);
    // See if the users is trying to display a month other than the current month.
    if ($yearmoday != NULL) {
        $display_mo = new Date();
        $display_mo->setDayMonthYear($yearmoday[2], $yearmoday[1], $yearmoday[0]);
    } else {
        $display_mo = new Date();
    }
    $LastDay = $display_mo->getYear() . "-" . $display_mo->getMonth() . "-" . $display_mo->GetDaysInMonth();
    $FirstDay = $display_mo->format("%Y") . "-" . $display_mo->format("%m") . "-" . "1";
    $sbr_type = array("s", "b", "r");
    $total_duration = array(0, 0, 0);
    $total_distance = array(0, 0, 0);
    $total_calories = array(0, 0, 0);
    for ($i = 0; $i < 3; $i++) {
        $query = "SELECT * FROM " . $wpdb->prefix . "flmain WHERE user_id=" . $userdata->ID . " AND workout_date>='" . $FirstDay . "' AND workout_date<='" . $LastDay . "' AND sbr_type='" . $sbr_type[$i] . "' ORDER BY workout_date ASC";
        $result = $wpdb->get_results($query, ARRAY_A);
        if ($result) {
            switch ($i) {
                case 0:
                    echo '<h2>Swimming</h2>';
                    break;
                case 1:
                    echo '<h2>Biking</h2>';
                    break;
                case 2:
                    echo '<h2>Running</h2>';
                    break;
            }
            echo '<table class="history">';
            echo '<tr><th width=80>Date</th><th>Duration</th><th>Distance</th>';
            echo '<th>Calories Burned</th><th>Avg RPMs</th><th>Pace</th><th>Time of Day</th>';
            echo '<th>Min HR</th><th>Avg HR</th><th>Max HR</th><th>Notes</th></tr>';
            foreach ($result as $row) {
                echo '<tr>';
                echo '<td><a href="/wp-content/plugins/fitnesslog/fitlogupdate.php?edit_date=';
                echo $row["workout_date"];
                echo '">';
                echo date("M d, Y", format_date($row["workout_date"]));
                echo '</a></td>';
                echo '<td>';
                echo $row["duration"];
                echo '</td>';
                echo '<td>';
                echo $row["distance"];
                echo '</td>';
                echo '<td>';
                echo $row["cals_burned"];
                echo '</td>';
                echo '<td>';
                echo $row["avg_rpms"];
                echo '</td>';
                echo '<td>';
                echo $row["pace"];
                echo '</td>';
                echo '<td>';
                echo $row["time_of_day"];
                echo '</td>';
                echo '<td>';
                echo $row["min_hr"];
                echo '</td>';
                echo '<td>';
                echo $row["avg_hr"];
                echo '</td>';
                echo '<td>';
                echo $row["max_hr"];
                echo '</td>';
                echo '<td>';
                echo stripslashes($row["notes"]);
                echo '</td>';
                echo '</tr>';
                //Add up the duration, distance and calories
                $total_duration[$i] = $total_duration[$i] + convert_time_seconds($row["duration"]);
                $total_distance[$i] = $total_distance[$i] + $row["distance"];
                $total_calories[$i] = $total_calories[$i] + $row["cals_burned"];
            }
            // Output the totals for each.
            echo '<tr><td>Totals</td><td>';
            echo format_time($total_duration[$i]);
            echo '</td>';
            echo '<td>';
            echo $total_distance[$i];
            echo '</td>';
            echo '<td>';
            echo $total_calories[$i];
            echo '</td></tr>';
        }
        echo '</table>';
    }
    // Close the session
    session_destroy();
}
示例#26
0
 /**
  * DB_DataObject_FormBuilder::_date2array()
  *
  * Takes a string representing a date or a unix timestamp and turns it into an
  * array suitable for use with the QuickForm data element.
  * When using a string, make sure the format can be handled by the PEAR::Date constructor!
  *
  * Beware: For the date conversion to work, you must at least use the letters "d", "m" and "Y" in
  * your format string (see "dateElementFormat" option). If you want to enter a time as well,
  * you will have to use "H", "i" and "s" as well. Other letters will not work! Exception: You can
  * also use "M" instead of "m" if you want plain text month names.
  *
  * @param mixed $date   A unix timestamp or the string representation of a date, compatible to strtotime()
  * @return array
  * @access protected
  */
 function _date2array($date)
 {
     $da = array();
     if (is_string($date)) {
         // Get PEAR::Date class definition, if needed
         include_once 'Date.php';
         $dObj = new Date($date);
         $da['d'] = $dObj->getDay();
         $da['l'] = $da['D'] = $dObj->getDayOfWeek();
         $da['m'] = $da['M'] = $da['F'] = $dObj->getMonth();
         $da['Y'] = $da['y'] = $dObj->getYear();
         $da['H'] = $dObj->getHour();
         $da['h'] = $da['H'] % 12;
         if ($da['h'] == 0) {
             $da['h'] = 12;
         }
         $da['i'] = $dObj->getMinute();
         $da['s'] = $dObj->getSecond();
         if ($da['H'] >= 12) {
             $da['a'] = 'pm';
             $da['A'] = 'PM';
         } else {
             $da['a'] = 'am';
             $da['A'] = 'AM';
         }
         unset($dObj);
     } else {
         if (is_int($date)) {
             $time = $date;
         } else {
             $time = time();
         }
         $da['d'] = date('d', $time);
         $da['l'] = $da['D'] = date('w', $time);
         $da['m'] = $da['M'] = $da['F'] = date('m', $time);
         $da['Y'] = $da['y'] = date('Y', $time);
         $da['H'] = date('H', $time);
         $da['h'] = date('h', $time);
         $da['i'] = date('i', $time);
         $da['s'] = date('s', $time);
         $da['a'] = date('a', $time);
         $da['A'] = date('A', $time);
     }
     $this->debug('<i>_date2array():</i> from ' . $date . ' ...');
     return $da;
 }
示例#27
0
 /**
  * DB_DataObject_FormBuilder::_date2array()
  *
  * Takes a string representing a date or a unix timestamp and turns it into an
  * array suitable for use with the QuickForm data element.
  * When using a string, make sure the format can be handled by the PEAR::Date constructor!
  *
  * Beware: For the date conversion to work, you must at least use the letters "d", "m" and "Y" in
  * your format string (see "dateElementFormat" option). If you want to enter a time as well,
  * you will have to use "H", "i" and "s" as well. Other letters will not work! Exception: You can
  * also use "M" instead of "m" if you want plain text month names.
  *
  * @param mixed $date   A unix timestamp or the string representation of a date, compatible to strtotime()
  * @return array
  * @access protected
  */
 function _date2array($date)
 {
     $da = array();
     if (is_string($date)) {
         if (preg_match('/^\\d+:\\d+(:\\d+|)(\\s+[ap]m|)$/i', $date)) {
             $date = date('Y-m-d ') . $date;
             $getDate = false;
         } else {
             $getDate = true;
         }
         include_once 'Date.php';
         $dObj = new Date($date);
         if ($getDate) {
             $da['d'] = $dObj->getDay();
             $da['l'] = $da['D'] = $dObj->getDayOfWeek();
             $da['m'] = $da['M'] = $da['F'] = $dObj->getMonth();
             $da['Y'] = $da['y'] = $dObj->getYear();
         }
         $da['H'] = $dObj->getHour();
         $da['h'] = $da['H'] % 12;
         if ($da['h'] == 0) {
             $da['h'] = 12;
         }
         $da['g'] = $da['h'];
         $da['i'] = $dObj->getMinute();
         $da['s'] = $dObj->getSecond();
         if ($da['H'] >= 12) {
             $da['a'] = 'pm';
             $da['A'] = 'PM';
         } else {
             $da['a'] = 'am';
             $da['A'] = 'AM';
         }
         unset($dObj);
     } else {
         if (is_int($date)) {
             $time = $date;
         } else {
             $time = time();
         }
         $da['d'] = date('d', $time);
         $da['l'] = $da['D'] = date('w', $time);
         $da['m'] = $da['M'] = $da['F'] = date('m', $time);
         $da['Y'] = $da['y'] = date('Y', $time);
         $da['H'] = date('H', $time);
         $da['g'] = date('g', $time);
         $da['h'] = date('h', $time);
         $da['i'] = date('i', $time);
         $da['s'] = date('s', $time);
         $da['a'] = date('a', $time);
         $da['A'] = date('A', $time);
     }
     DB_DataObject_FormBuilder::debug('<i>_date2array():</i> from ' . $date . ' to ' . serialize($da) . ' ...');
     return $da;
 }
示例#28
0
 /**
  * Specifically handle month recurrence
  *
  * This method will take care of parsing the month
  * recurrence data and correctly rescheduling a
  * scan if the recurrence time has been met
  *
  * @param array $parameters Array of the parameters
  *	from the database entry for this recurrence
  *	setting
  */
 private function handle_month_recurrence($parameters)
 {
     $the_interval = $parameters['the_interval'];
     $profile_id = $parameters['profile_id'];
     $date_scheduled = $parameters['date_scheduled'];
     $rules_string = $parameters['rules_string'];
     $specific_time = $this->specific_time($parameters['specific_time']);
     // The monthly rules string is colon delimited with a max of 3 items
     $tmp = explode(':', $rules_string);
     // The type of monthly recursion will be 'day' or 'gen'
     $type = $tmp[0];
     // This is either the day of the month, or a relative day of the week
     $day = $tmp[1];
     /**
      * Take the date the scan was scheduled, and only return the
      * year and month because my calculations are based off of the 0th
      * day of the month at midnight. Using 0th day because of how 
      * strtotime determines it's offset
      */
     $month_time = strtotime($date_scheduled);
     $month_time = strftime("%Y-%m-00 00:00:00", $month_time);
     /**
      * Get X months in the future from the last date scheduled
      * Because the remaining date calculations will be based
      * off of that future time.
      */
     $time = strtotime("+{$the_interval} month", strtotime($month_time));
     /**
      * Turn the future date into PEAR object so I can use
      * the PEAR object's methods.
      */
     $future_date = new Date($time);
     $future_month = $future_date->getMonth();
     $future_year = $future_date->getYear();
     switch ($type) {
         case "gen":
             // Get the weekday that was specified
             $weekday = $this->get_weekday_fullname($tmp[2]);
             // Get the number of days in the month
             $days_in_month = Date_Calc::daysInMonth($future_month, $future_year);
             /**
              * Turn the above into an array where the day of the
              * month is the value. The last value will be the last
              * day of the month
              */
             for ($day = 1; $day <= $days_in_month; $day++) {
                 $days[] = $day;
             }
             $days_in_month = $days;
             switch ($day) {
                 case "1st":
                     $day = $this->get_relative_day($days_in_month, $future_month, $future_year, $weekday);
                     $future_date->setDay($day);
                     break;
                 case "2nd":
                     $day = $this->get_relative_day($days_in_month, $future_month, $future_year, $weekday, 2);
                     $future_date->setDay($day);
                     break;
                 case "3rd":
                     $day = $this->get_relative_day($days_in_month, $future_month, $future_year, $weekday, 3);
                     $future_date->setDay($day);
                     break;
                 case "4th":
                     $day = $this->get_relative_day($days_in_month, $future_month, $future_year, $weekday, 4);
                     $future_date->setDay($day);
                     break;
                 case "last":
                     $days_in_month = array_reverse($days_in_month);
                     /**
                      * I reversed the array above, so in essence we're
                      * starting from the end of the month, therefore the
                      * "last" day of the month will, in this case, be
                      * the first match
                      */
                     $day = $this->get_relative_day($days_in_month, $future_month, $future_year, $weekday);
                     $future_date->setDay($day);
                     break;
                 case "2_last":
                     $days_in_month = array_reverse($days_in_month);
                     /**
                      * I reversed the array above, so in essence we're
                      * starting from the end of the month, therefore the
                      * "2nd to last" day of the month will, in this case, be
                      * the second match
                      */
                     $day = $this->get_relative_day($days_in_month, $future_month, $future_year, $weekday, 2);
                     $future_date->setDay($day);
                     break;
             }
             break;
         default:
             $future_date->setDay($day);
             break;
     }
     $future_date = $this->set_new_time($future_date, $specific_time);
     // Compare the dates
     if ($this->today->after($future_date)) {
         // Update the date scheduled field
         $this->reschedule_scan($profile_id, $this->today->getDate());
         // Reschedule the scan
         $this->update_scan_status($profile_id, 'F', 'P');
     }
 }
示例#29
0
 public function getNextRunTime($date)
 {
     // check if $date is a timestamp...
     if ($date instanceof Date == false && is_integer($date)) {
         $date = new Date($date);
     }
     // assume now $date IS instanceof Date
     $cSecond = $date->getSecond();
     $cMinute = $date->getMinute();
     $cHour = $date->getHour();
     $cDay = $date->getDay();
     $cMonth = $date->getMonth();
     $cYear = $date->getYear();
     // required to check the number of days in the month
     $found = false;
     while ($found === false) {
         while ($found === false) {
             // iterate months...
             $cMonth = $this->findNextInArray($cMonth, $this->monthArray);
             if ($cMonth === null) {
                 break;
             }
             // find the day now
             while ($found === false) {
                 $cDay = $this->findNextInArray($cDay, $this->dayArray);
                 if ($cDay === null) {
                     break;
                 }
                 // here dayOfWeek and number of days in month should be checked!
                 $date = new Date();
                 $date->setYear($cYear);
                 $date->setMonth($cMonth);
                 $numberOfDaysInMonth = $date->getDaysInMonth();
                 if ($cDay > $numberOfDaysInMonth) {
                     break;
                 }
                 if ($this->dayOfWeekArray !== null) {
                     // get day of the week
                     $date->setDay($cDay);
                     $dayOfWeek = $date->getDayOfWeek();
                     if (!in_array($dayOfWeek, $this->dayOfWeekArray)) {
                         $cDay++;
                         continue;
                     }
                 }
                 while ($found === false) {
                     if ($cHour == 24) {
                         break;
                     }
                     $cHour = $this->findNextInArray($cHour, $this->hourArray);
                     if ($cHour === null) {
                         break;
                     }
                     while ($found === false) {
                         if ($cMinute == 60) {
                             break;
                         }
                         $cMinute = $this->findNextInArray($cMinute, $this->minuteArray);
                         if ($cMinute === null) {
                             break;
                         }
                         while ($found === false) {
                             if ($cSecond == 60) {
                                 break;
                             }
                             $cSecond = $this->findNextInArray($cSecond, $this->secondArray);
                             if ($cSecond === null) {
                                 break;
                             } else {
                                 // FOUND IT!!! WOOOO!
                                 // create Date object
                                 $date = new Date();
                                 $date->setYear($cYear);
                                 $date->setMonth($cMonth);
                                 $date->setDay($cDay);
                                 $date->setHour($cHour);
                                 $date->setMinute($cMinute);
                                 $date->setSecond($cSecond);
                                 return $date;
                             }
                         }
                         $cMinute++;
                         $cSecond = 0;
                     }
                     $cHour++;
                     $cMinute = 0;
                     $cSecond = 0;
                 }
                 $cDay++;
                 $cHour = 0;
                 $cMinute = 0;
                 $cSecond = 0;
             }
             $cMonth++;
             $cDay = 0;
             $cHour = 0;
             $cMinute = 0;
             $cSecond = 0;
         }
         $cYear++;
         $cMonth = 0;
         $cDay = 0;
         $cHour = 0;
         $cMinute = 0;
         $cSecond = 0;
     }
 }
示例#30
0
 /**
  * Set a given timezone for the passed date. Really modifies
  * the date as just the timezone is exchanged, no further
  * modifications are done.
  *
  * @param   util.Date date
  * @param   util.TimeZone tz
  * @return  util.Date
  */
 public static function setTimezone(Date $date, TimeZone $tz)
 {
     return Date::create($date->getYear(), $date->getMonth(), $date->getDay(), $date->getHours(), $date->getMinutes(), $date->getSeconds(), $tz);
 }