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; }
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); }
public function getLinks() { $oDate = new Date($this->oStart); $oNow = new Date(); $aLinks = array(); $baseUrl = parent::getUrl(false); $year = $oDate->getYear(); $aLinks['prev'] = array('label' => '< ' . ($year - 1), 'url' => $this->appendToUrl($baseUrl, 'year=' . ($year - 1))); $oDate->setYear($year + 1); $aLinks['next'] = array('label' => $year + 1 . ' >'); if ($oNow->after($oDate)) { $aLinks['next']['url'] = $this->appendToUrl($baseUrl, 'year=' . ($year + 1)); } return $aLinks; }
public function getLinks() { $oDate = new Date($this->oStart); $oNow = new Date(); $aLinks = array(); $baseUrl = parent::getUrl(false); $date = $oDate->getYear(); $aLinks['up'] = array('label' => $date, 'url' => $this->appendToUrl($baseUrl, 'year=' . $date)); $oDate->subtractSpan(new Date_Span('1-0-0-0')); $date = $oDate->format('%Y-%m'); $aLinks['prev'] = array('label' => '< ' . $date, 'url' => $this->appendToUrl($baseUrl, 'month=' . $date)); $oDate->addSpan(new Date_Span('34-0-0-0')); $date = $oDate->format('%Y-%m'); $aLinks['next'] = array('label' => $date . ' >'); if ($oNow->after($oDate)) { $aLinks['next']['url'] = $this->appendToUrl($baseUrl, 'month=' . $date); } return $aLinks; }
public function isEquals(Date $date) { return $this->year === $date->getYear() && $this->month === $date->getMonth() && $this->day === $date->getDay(); }
/** * Returns an array of conversions. * * @param array $aParams * @return array */ function getConversions($aParams) { $conf = $GLOBALS['_MAX']['CONF']; $oDbh =& OA_DB::singleton(); $where = ''; if (!empty($aParams['day'])) { $aParams['day_begin'] = $aParams['day_end'] = $aParams['day']; } if (!empty($aParams['day_begin'])) { $oStart = new Date($aParams['day_begin']); $oStart->setHour(0); $oStart->setMinute(0); $oStart->setSecond(0); $oStart->toUTC(); $where .= ' AND ac.tracker_date_time >= ' . $oDbh->quote($oStart->format('%Y-%m-%d %H:%M:%S'), 'timestamp'); } if (!empty($aParams['day_end'])) { $oEnd = new Date($aParams['day_end']); $oEnd->setHour(23); $oEnd->setMinute(59); $oEnd->setSecond(59); $oEnd->toUTC(); $where .= ' AND ac.tracker_date_time <= ' . $oDbh->quote($oEnd->format('%Y-%m-%d %H:%M:%S'), 'timestamp'); } if (!empty($aParams['month'])) { $oStart = new Date("{$aParams['month']}-01"); $oStart->setHour(0); $oStart->setMinute(0); $oStart->setSecond(0); $oEnd = new Date(Date_Calc::beginOfNextMonth($oStart->getDay(), $oStart->getMonth, $oStart->getYear(), '%Y-%m-%d')); $oEnd->setHour(0); $oEnd->setMinute(0); $oEnd->setSecond(0); $oEnd->subtractSeconds(1); $oStart->toUTC(); $oEnd->toUTC(); $where .= ' AND ac.tracker_date_time >= ' . $oDbh->quote($oStart->format('%Y-%m-%d %H:%M:%S'), 'timestamp'); $where .= ' AND ac.tracker_date_time <= ' . $oDbh->quote($oEnd->format('%Y-%m-%d %H:%M:%S'), 'timestamp'); } if (!empty($aParams['day_hour'])) { $oStart = new Date("{$aParams['day_hour']}:00:00"); $oStart->setMinute(0); $oStart->setSecond(0); $oEnd = new Date($oStart); $oStart->setMinute(59); $oStart->setSecond(59); $where .= ' AND ac.tracker_date_time >= ' . $oDbh->quote($oStart->format('%Y-%m-%d %H:%M:%S'), 'timestamp'); $where .= ' AND ac.tracker_date_time <= ' . $oDbh->quote($oEnd->format('%Y-%m-%d %H:%M:%S'), 'timestamp'); } if (!empty($aParams['agency_id'])) { $where .= ' AND c.agencyid=' . $oDbh->quote($aParams['agency_id'], 'integer'); } if (!empty($aParams['clientid'])) { $where .= ' AND c.clientid=' . $oDbh->quote($aParams['clientid'], 'integer'); } if (isset($aParams['zonesIds'])) { $where .= ' AND ac.zone_id IN (' . $oDbh->escape(implode(',', $aParams['zonesIds'])) . ")"; } if (!empty($aParams['campaignid'])) { $where .= ' AND m.campaignid=' . $oDbh->quote($aParams['campaignid'], 'integer'); } if (!empty($aParams['bannerid'])) { $where .= ' AND d.bannerid=' . $oDbh->quote($aParams['bannerid'], 'integer'); } if (!empty($aParams['statuses'])) { $where .= ' AND ac.connection_status IN (' . $oDbh->escape(implode(',', $aParams['statuses'])) . ')'; } if (isset($aParams['startRecord']) && is_numeric($aParams['startRecord']) && is_numeric($aParams['perPage'])) { $limit = ' LIMIT ' . $oDbh->quote($aParams['perPage'], 'text', false) . ' OFFSET ' . $oDbh->quote($aParams['startRecord'], 'text', false); } elseif (!empty($aParams['perPage'])) { $limit = ' LIMIT ' . $oDbh->quote($aParams['perPage'], 'integer', false) . ' OFFSET 0'; } else { $limit = ''; } $query = "SELECT\n ac.data_intermediate_ad_connection_id as connection_id,\n c.clientid,\n m.campaignid,\n m.campaignname AS campaignname,\n ac.tracker_id as tracker_id,\n ac.connection_status,\n ac.connection_date_time AS connection_date_time,\n ac.tracker_date_time as date_time,\n t.trackername,\n ac.tracker_ip_address,\n ac.tracker_country,\n ac.connection_action,\n t.type AS connection_type,\n ac.tracker_country,\n ac.ad_id,\n ac.creative_id,\n ac.zone_id,\n ac.comments\n FROM\n {$conf['table']['prefix']}{$conf['table']['clients']} AS c,\n {$conf['table']['prefix']}{$conf['table']['data_intermediate_ad_connection']} AS ac,\n {$conf['table']['prefix']}{$conf['table']['banners']} AS d,\n {$conf['table']['prefix']}{$conf['table']['campaigns']} AS m,\n {$conf['table']['prefix']}{$conf['table']['trackers']} AS t\n WHERE\n c.clientid=m.clientid\n AND m.campaignid=d.campaignid\n AND d.bannerid=ac.ad_id\n AND t.trackerid=ac.tracker_id\n AND ac.inside_window = 1\n " . $where . "\n ORDER BY\n ac.tracker_date_time\n {$limit}"; $aStats = $oDbh->queryAll($query, null, MDB2_FETCHMODE_DEFAULT, true); $oNow = new Date(); foreach (array_keys($aStats) as $k) { $oDate = new Date($aStats[$k]['date_time']); $oDate->setTZbyID('UTC'); $oDate->convertTZ($oNow->tz); $aStats[$k]['date_time'] = $oDate->format('%Y-%m-%d %H:%M:%S'); $oDate = new Date($aStats[$k]['connection_date_time']); $oDate->setTZbyID('UTC'); $oDate->convertTZ($oNow->tz); $aStats[$k]['connection_date_time'] = $oDate->format('%Y-%m-%d %H:%M:%S'); } return $aStats; }
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; }
/** * 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 get_prior_year($template, $userID, $connection) { $calc = new Date_Calc(); $beg_date = new Date(); $end_date = new Date(); $beg_date->addYears(-1); // Get current month dates. $beg_date->setDayMonthYear(1, 1, $beg_date->getYear()); $end_date->setDayMonthYear(31, 12, $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("PRIORYR"); $template->setVariable("MONTHNAME", $beg_date->format("%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(); }
/** * 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; } } } }
/** * A method to modify an array of history data so that it can be displayed in a format * compatible with the weekly breakdown template. * * @param array $aData A reference to an array of arrays, containing the rows of data. * @param object $oCaller The calling object. Expected to have the the class variable * "statsBreakdown" set. */ function prepareWeekBreakdown(&$aData, $oCaller) { // Only prepare the weekly breakdown if the statsBreakdown // in the caller is set to "week" if ($oCaller->statsBreakdown != 'week') { return; } $beginOfWeek = OA_Admin_DaySpan::getBeginOfWeek(); $aWeekData = array(); ksort($aData); foreach ($aData as $key => $aRowData) { // Get the date for this row's data $oDate = new Date($key); if ($beginOfWeek != 0) { // Need to change the date used for the data so // that the day appears in the correct week $daysToGoback = (int) (SECONDS_PER_DAY * $beginOfWeek); $oDate->subtractSeconds($daysToGoback); } // Get the week this date is in, in YYYY-MM format $week = sprintf('%04d-%02d', $oDate->getYear(), $oDate->getWeekOfYear()); // Prepare the data array for this week, if not set, where // the week is in the "week" index, there is a "data" index // for all the rows that make up the week, and the array // has all the columns of an empty data row if (!isset($aWeekData[$week])) { $aWeekData[$week] = $oCaller->aEmptyRow; $aWeekData[$week]['week'] = $week; $aWeekData[$week]['data'] = array(); } // Add the data from the row to the totals of the week foreach (array_keys($oCaller->aColumns) as $colKey) { $aWeekData[$week][$colKey] += $aRowData[$colKey]; } // Store the row in the week $aWeekData[$week]['data'][$key] = $aRowData; } foreach (array_keys($aWeekData) as $week) { // Now that the totals are complete, fill any // remaining days in the week with empty data $days = count($aWeekData[$week]['data']); if ($days < 7) { // Locate the first day of the week in the days that make // up the week so far ksort($aWeekData[$week]['data']); $key = key($aWeekData[$week]['data']); $oDate = new Date($key); $firstDataDayOfWeek = $oDate->getDayOfWeek(); // Is this after the start of the week? if ($firstDataDayOfWeek > $beginOfWeek) { // Change the date to be the first day of this week $daysToGoback = (int) (SECONDS_PER_DAY * ($firstDataDayOfWeek - $beginOfWeek)); $oDate->subtractSeconds($daysToGoback); } // Check each day in the week for ($counter = 0; $counter < 7; $counter++) { if (is_null($aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')])) { // Set the day's data to the empty row, plus the "day" heading for the day $aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')] = $oCaller->aEmptyRow; $aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')]['day'] = $oDate->format($GLOBALS['date_format']); } elseif (!is_null($aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')]) && !array_key_exists('day', $aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')])) { $aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')]['day'] = $oDate->format($GLOBALS['date_format']); } $oDate->addSeconds(SECONDS_PER_DAY); } } // Ensure the day data is sorted correctly ksort($aWeekData[$week]['data']); // Format all day rows foreach (array_keys($aWeekData[$week]['data']) as $key) { $oCaller->_formatStatsRowRecursive($aWeekData[$week]['data'][$key]); } // Calculate CTR and other columns, making sure that the method is available if (is_callable(array($oCaller, '_summarizeStats'))) { $oCaller->_summarizeStats($aWeekData[$week]); } } // Set the new weekly-formatted data as the new data array to use $aData = $aWeekData; }
function UInterface() { global $configArray; global $timer; $local = $configArray['Site']['local']; $this->vufindTheme = $configArray['Site']['theme']; $this->isMobile = mobile_device_detect(); $this->assign('isMobile', $this->isMobile ? 'true' : 'false'); $this->assign('device', get_device_name()); //Figure out google translate id if (isset($configArray['Translation']['google_translate_key']) && strlen($configArray['Translation']['google_translate_key']) > 0) { $this->assign('google_translate_key', $configArray['Translation']['google_translate_key']); $this->assign('google_included_languages', $configArray['Translation']['includedLanguages']); } $thisYear = new Date(); $this->assign('lastYear', $thisYear->getYear() - 1); if (isset($_REQUEST['print'])) { $this->assign('print', true); } // Check to see if multiple themes were requested; if so, build an array, // otherwise, store a single string. $themeArray = explode(',', $this->vufindTheme); //Make sure we always fall back to the default theme so a template does not have to be overridden. $themeArray[] = 'default'; if (count($themeArray) > 1) { $this->template_dir = array(); foreach ($themeArray as $currentTheme) { $currentTheme = trim($currentTheme); $this->template_dir[] = "{$local}/interface/themes/{$currentTheme}"; } } else { $this->template_dir = "{$local}/interface/themes/{$this->vufindTheme}"; } $this->themes = $themeArray; if (isset($timer)) { $timer->logTime('Set theme'); } // Create an MD5 hash of the theme name -- this will ensure that it's a // writeable directory name (since some config.ini settings may include // problem characters like commas or whitespace). $md5 = md5($this->vufindTheme); $this->compile_dir = "{$local}/interface/compile/{$md5}"; if (!is_dir($this->compile_dir)) { if (!mkdir($this->compile_dir)) { echo "Could not create compile directory {$this->compile_dir}"; die; } } $this->cache_dir = "{$local}/interface/cache/{$md5}"; if (!is_dir($this->cache_dir)) { if (!mkdir($this->cache_dir)) { echo "Could not create cache directory {$this->cache_dir}"; die; } } $this->plugins_dir = array('plugins', "{$local}/interface/plugins"); $this->caching = false; $this->debug = true; $this->compile_check = true; unset($local); $this->register_block('display_if_inconsistent', 'display_if_inconsistent'); $this->register_block('display_if_set', 'display_if_set'); $this->register_function('translate', 'translate'); $this->register_function('char', 'char'); $this->assign('site', $configArray['Site']); $this->assign('path', $configArray['Site']['path']); $defaultConfig = $configArray['Site']['path']; $url = $_SERVER['SERVER_NAME']; if (isset($_SERVER['HTTPS'])) { $url = "https://" . $url; } else { $url = "http://" . $url; } if (strlen($configArray['Site']['path']) > 0) { $url .= '/' . $configArray['Site']['path']; } $this->url = $url; $this->assign('template_dir', $this->template_dir); $this->assign('url', $url); $this->assign('coverUrl', $configArray['Site']['coverUrl']); $this->assign('fullPath', str_replace('&', '&', $_SERVER['REQUEST_URI'])); $this->assign('requestHasParams', strpos($_SERVER['REQUEST_URI'], '?') > 0); if (isset($configArray['Site']['email'])) { $this->assign('supportEmail', $configArray['Site']['email']); } if (isset($configArray['Site']['libraryName'])) { $this->assign('consortiumName', $configArray['Site']['libraryName']); } $this->assign('libraryName', $configArray['Site']['title']); $this->assign('ils', $configArray['Catalog']['ils']); if (isset($configArray['Catalog']['url'])) { $this->assign('classicCatalogUrl', $configArray['Catalog']['url']); } else { if (isset($configArray['Catalog']['hipUrl'])) { $this->assign('classicCatalogUrl', $configArray['Catalog']['hipUrl']); } } $this->assign('showConvertListsFromClassic', $configArray['Catalog']['showConvertListsFromClassic']); $this->assign('theme', $this->vufindTheme); $this->assign('primaryTheme', reset($themeArray)); $this->assign('device', get_device_name()); $timer->logTime('Basic configuration'); $this->assign('currentTab', 'Search'); $this->assign('authMethod', $configArray['Authentication']['method']); if ($configArray['System']['debug']) { $this->assign('debug', true); } if ($configArray['System']['debugJs']) { $this->assign('debugJs', true); } if (isset($configArray['System']['debugCss']) && $configArray['System']['debugCss']) { $this->assign('debugCss', true); } // Detect Internet Explorer 8 to include respond.js for responsive css support if (isset($_SERVER['HTTP_USER_AGENT'])) { $ie8 = stristr($_SERVER['HTTP_USER_AGENT'], 'msie 8') || stristr($_SERVER['HTTP_USER_AGENT'], 'trident/5'); //trident/5 should catch ie9 compability modes $this->assign('ie8', $ie8); } $session = new Session(); $session->session_id = session_id(); if ($session->find(true)) { $this->assign('session', session_id() . ', remember me ' . $session->remember_me); } else { $this->assign('session', session_id() . ' - not saved'); } }
function next_payment_date($pdate = '') { $date = new Date($pdate ? $pdate : $this->data['xp_pmt_date']); switch ($this->data['payment_frequency']) { case "W": $date->addSeconds(7 * 24 * 60 * 60); break; case "BW": $date->addSeconds(14 * 24 * 60 * 60); break; case "M": $date->addSeconds($date->getDaysInMonth() * 24 * 60 * 60); break; case "Q": $date->addSeconds($date->getDaysInMonth() * 24 * 60 * 60); $date->addSeconds($date->getDaysInMonth() * 24 * 60 * 60); $date->addSeconds($date->getDaysInMonth() * 24 * 60 * 60); break; case "SA": $date->addSeconds($date->getDaysInMonth() * 24 * 60 * 60); $date->addSeconds($date->getDaysInMonth() * 24 * 60 * 60); $date->addSeconds($date->getDaysInMonth() * 24 * 60 * 60); $date->addSeconds($date->getDaysInMonth() * 24 * 60 * 60); $date->addSeconds($date->getDaysInMonth() * 24 * 60 * 60); $date->addSeconds($date->getDaysInMonth() * 24 * 60 * 60); break; case "A": $date->setYear($date->getYear() + 1); break; } return $date->format('%Y-%m-%d'); }
/** * @covers Geissler\Converter\Model\Date::getYear */ public function testGetYear() { $this->assertInstanceOf($this->class, $this->object->setYear(1984)); $this->assertEquals(1984, $this->object->getYear()); }
/** * 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; }
/** * 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']); } }
/** * 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); }
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())); }
/** * 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(); }
/** * 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); }
function showSelectPage() { global $tpl; global $us; global $badgerDb; handleOldFinishedTransactions(new AccountManager($badgerDb)); $widgets = new WidgetEngine($tpl); $widgets->addCalendarJS(); $widgets->addToolTipJS(); $tpl->addJavaScript("js/behaviour.js"); $tpl->addJavaScript("js/prototype.js"); $tpl->addJavaScript("js/statistics.js"); $tpl->addHeaderTag('<script type="text/javascript">var badgerHelpChapter = "Statistiken";</script>'); $dataGrid = new DataGrid($tpl); $dataGrid->sourceXML = BADGER_ROOT . "/core/XML/getDataGridXML.php?q=AccountManager"; $dataGrid->headerName = array(getBadgerTranslation2('statistics', 'accColTitle'), getBadgerTranslation2('statistics', 'accColBalance'), getBadgerTranslation2('statistics', 'accColCurrency')); $dataGrid->columnOrder = array("title", "balance", 'currency'); $dataGrid->initialSort = "title"; $dataGrid->initialSortDirection = "asc"; $dataGrid->headerSize = array(160, 100, 75); $dataGrid->cellAlign = array("left", 'right', 'left'); $dataGrid->width = '30em'; $dataGrid->height = '7em'; $dataGrid->initDataGridJS(); try { $preselectedAccounts = $us->getProperty('statisticsPreselectedAccounts'); foreach ($preselectedAccounts as $currentPreselectedAccount) { $tpl->addOnLoadEvent("dgPreselectId('{$currentPreselectedAccount}');"); } } catch (BadgerException $ex) { } $tpl->addOnLoadEvent("Behaviour.register(statisticsBehaviour);"); $tpl->addOnLoadEvent("Behaviour.apply();"); $widgets->addNavigationHead(); $selectTitle = getBadgerTranslation2('statistics', 'pageTitle'); echo $tpl->getHeader($selectTitle); $widgets->addToolTipLayer(); $selectFormAction = BADGER_ROOT . '/modules/statistics/statistics.php'; $graphTypeText = getBadgerTranslation2('statistics', 'type'); $categoryTypeText = getBadgerTranslation2('statistics', 'category'); $timeFrameText = getBadgerTranslation2('statistics', 'period'); $summarizeCategoriesText = getBadgerTranslation2('statistics', 'catMerge'); $accountsText = getBadgerTranslation2('statistics', 'accounts'); $differentCurrencyWarningText = getBadgerTranslation2('statistics', 'attention'); $fromText = getBadgerTranslation2('statistics', 'from'); $toText = getBadgerTranslation2('statistics', 'to'); $trendRadio = $widgets->createField('mode', null, 'trendPage', '', false, 'radio', 'checked="checked"'); $trendLabel = $widgets->createLabel('mode', getBadgerTranslation2('statistics', 'trend')); $categoryRadio = $widgets->createField('mode', null, 'categoryPage', '', false, 'radio'); $categoryLabel = $widgets->createLabel('mode', getBadgerTranslation2('statistics', 'categories')); $accountSelect = $dataGrid->writeDataGrid(); $accountField = $widgets->createField('accounts', null, null, '', false, 'hidden'); $monthArray = array('fullYear' => getBadgerTranslation2('statistics', 'fullYear'), '1' => getBadgerTranslation2('statistics', 'jan'), '2' => getBadgerTranslation2('statistics', 'feb'), '3' => getBadgerTranslation2('statistics', 'mar'), '4' => getBadgerTranslation2('statistics', 'apr'), '5' => getBadgerTranslation2('statistics', 'may'), '6' => getBadgerTranslation2('statistics', 'jun'), '7' => getBadgerTranslation2('statistics', 'jul'), '8' => getBadgerTranslation2('statistics', 'aug'), '9' => getBadgerTranslation2('statistics', 'sep'), '10' => getBadgerTranslation2('statistics', 'oct'), '11' => getBadgerTranslation2('statistics', 'nov'), '12' => getBadgerTranslation2('statistics', 'dec')); $monthSelect = $widgets->createSelectField('monthSelect', $monthArray, 'fullYear', '', false, 'onchange="updateDateRange();"'); $now = new Date(); $beginOfYear = new Date(); $beginOfYear->setMonth(1); $beginOfYear->setDay(1); $yearInput = $widgets->createField('yearSelect', 4, $now->getYear(), '', false, 'text', 'onchange="updateDateRange();"'); $startDateField = $widgets->addDateField("startDate", $beginOfYear->getFormatted()); $endDateField = $widgets->addDateField("endDate", $now->getFormatted()); $inputRadio = $widgets->createField('type', null, 'i', '', false, 'radio', 'checked="checked"'); $inputLabel = $widgets->createLabel('type', getBadgerTranslation2('statistics', 'income')); $outputRadio = $widgets->createField('type', null, 'o', '', false, 'radio'); $outputLabel = $widgets->createLabel('type', getBadgerTranslation2('statistics', 'expenses')); $summarizeRadio = $widgets->createField('summarize', null, 't', '', false, 'radio', 'checked="checked"'); $summarizeLabel = $widgets->createLabel('summarize', getBadgerTranslation2('statistics', 'subCat')); $distinguishRadio = $widgets->createField('summarize', null, 'f', '', false, 'radio'); $distinguishLabel = $widgets->createLabel('summarize', getBadgerTranslation2('statistics', 'subCat2')); $dateFormatField = $widgets->createField('dateFormat', null, $us->getProperty('badgerDateFormat'), null, false, 'hidden'); $errorMsgAccountMissingField = $widgets->createField('errorMsgAccountMissing', null, getBadgerTranslation2('statistics', 'errorMissingAcc'), null, false, 'hidden'); $errorMsgStartBeforeEndField = $widgets->createField('errorMsgStartBeforeEnd', null, getBadgerTranslation2('statistics', 'errorDate'), null, false, 'hidden'); $errorMsgEndInFutureField = $widgets->createField('errorMsgEndInFuture', null, getBadgerTranslation2('statistics', 'errorEndDate'), null, false, 'hidden'); $submitButton = $widgets->createButton('submit', getBadgerTranslation2('statistics', 'showButton'), 'submitSelect();', "Widgets/accept.gif"); eval('echo "' . $tpl->getTemplate('statistics/select') . '";'); eval('echo "' . $tpl->getTemplate('badgerFooter') . '";'); }
/** * 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; }
function get_summary_totals($activity, $term) { $beg_date = new Date(); $end_date = new Date(); global $wpdb; global $userdata; get_currentuserinfo(); // First figure out what term we are looking for. // "w" for Weekly // "m" for Monthly // "A" for Annual switch ($term) { case "w": //Get weekly dates $day_of_wk = $beg_date->getDayOfWeek(); $beg_date->addDays(-($day_of_wk - 1)); $end_date->copy($beg_date); $end_date->addDays(6); break; case "m": //Get monthly dates $beg_date->setDayMonthYear(1, $beg_date->getMonth(), $beg_date->getYear()); $end_date->copy($beg_date); $end_date->addDays($end_date->getDaysInMonth() - 1); break; case "a": //Get the annual dates. $beg_date->setDayMonthYear(1, 1, $beg_date->getYear()); $end_date->setDayMonthYear(31, 12, $end_date->getYear()); break; case "pm": //Get the prior months date. $beg_date->setDayMonthYear(1, $beg_date->getMonth(), $beg_date->getYear()); $end_date = $beg_date->getPrevDay(); $beg_date->setDayMonthYear(1, $end_date->getMonth(), $end_date->getYear()); break; case "ppm": //Get the dates for two months from now. $beg_date->setDayMonthYear(1, $beg_date->getMonth(), $beg_date->getYear()); $end_date = $beg_date->getPrevDay(); $beg_date->setDayMonthYear(1, $end_date->getMonth(), $end_date->getYear()); $end_date = $beg_date->getPrevDay(); $beg_date->setDayMonthYear(1, $end_date->getMonth(), $end_date->getYear()); break; case "pppm": //Get the dates for three months from now. $beg_date->setDayMonthYear(1, $beg_date->getMonth(), $beg_date->getYear()); $end_date = $beg_date->getPrevDay(); $beg_date->setDayMonthYear(1, $end_date->getMonth(), $end_date->getYear()); $end_date = $beg_date->getPrevDay(); $beg_date->setDayMonthYear(1, $end_date->getMonth(), $end_date->getYear()); $end_date = $beg_date->getPrevDay(); $beg_date->setDayMonthYear(1, $end_date->getMonth(), $end_date->getYear()); break; case "py": //Get the dates for the prior year. $beg_date->setDayMonthYear(1, 1, $beg_date->getYear() - 1); $end_date->setDayMonthYear(31, 12, $beg_date->getYear()); break; } switch ($activity) { case "s": // Get the summary of swim duration. $query = "SELECT user_id, SUM(seconds) AS seconds, SUM(distance) AS distance FROM " . $wpdb->prefix . "flmain WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND sbr_type='" . $activity . "' AND user_id=" . $userdata->ID . " GROUP BY user_id"; break; case "b": // Get the summary of bike duration. $query = "SELECT user_id, SUM(seconds) AS seconds, SUM(distance) AS distance FROM " . $wpdb->prefix . "flmain WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND sbr_type='" . $activity . "' AND user_id=" . $userdata->ID . " GROUP BY user_id"; break; case "r": // Get the summary of run duration. $query = "SELECT user_id, SUM(seconds) AS seconds, SUM(distance) AS distance FROM " . $wpdb->prefix . "flmain WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND sbr_type='" . $activity . "' AND user_id=" . $userdata->ID . " GROUP BY user_id"; break; case "str": // Get the summary of strength duration. $query = "SELECT user_id, SUM(seconds) AS seconds FROM " . $wpdb->prefix . "flstrength WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userdata->ID . " GROUP BY user_id"; break; } $result = $wpdb->get_results($query, ARRAY_A); if ($result) { foreach ($result as $row) { // Format the string for out put now. $time = format_time($row["seconds"]); $time_array = explode(":", $time); if ($activity == "s") { $distance = "yds"; } else { $distance = "miles"; } $output = $time_array[0] . "hrs " . $time_array[1] . "mins " . $time_array[2] . "secs " . $row["distance"] . $distance; } } else { $output = 0; } return $output; }
public static function dayDifference(Date $left, Date $right) { return gregoriantojd($right->getMonth(), $right->getDay(), $right->getYear()) - gregoriantojd($left->getMonth(), $left->getDay(), $left->getYear()); }
/** * 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; }
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();
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; } }
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()); }