/** * Check start/end dates - note that check is the reverse of normal check: * if the operation interval is <= 60, must be start/end of an hour, to * make sure we update all the operation intervals in the hour, and if * the operation interval > 60, must be the start/end of an operation * interval, to make sure we update all the hours in the operation interval. * * @static * @param Date $oStartDate * @param Date $oEndDate * @return boolean */ function checkDates($oStartDate, $oEndDate) { $aConf = $GLOBALS['_MAX']['CONF']; $operationInterval = $aConf['maintenance']['operation_interval']; if ($operationInterval <= 60) { // Must ensure that only one hour is being summarised if (!OX_OperationInterval::checkDatesInSameHour($oStartDate, $oEndDate)) { return false; } // Now check that the start and end dates are match the start and // end of the hour $oHourStart = new Date(); $oHourStart->setYear($oStartDate->getYear()); $oHourStart->setMonth($oStartDate->getMonth()); $oHourStart->setDay($oStartDate->getDay()); $oHourStart->setHour($oStartDate->getHour()); $oHourStart->setMinute('00'); $oHourStart->setSecond('00'); $oHourEnd = new Date(); $oHourEnd->setYear($oEndDate->getYear()); $oHourEnd->setMonth($oEndDate->getMonth()); $oHourEnd->setDay($oEndDate->getDay()); $oHourEnd->setHour($oEndDate->getHour()); $oHourEnd->setMinute('59'); $oHourEnd->setSecond('59'); if (!$oStartDate->equals($oHourStart)) { return false; } if (!$oEndDate->equals($oHourEnd)) { return false; } } else { // Must ensure that only one operation interval is being summarised $operationIntervalID = OX_OperationInterval::convertDaySpanToOperationIntervalID($oStartDate, $oEndDate, $operationInterval); if (is_bool($operationIntervalID) && !$operationIntervalID) { return false; } // Now check that the start and end dates match the start and end // of the operation interval list($oOperationIntervalStart, $oOperationIntervalEnd) = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($oStartDate, $operationInterval); if (!$oStartDate->equals($oOperationIntervalStart)) { return false; } if (!$oEndDate->equals($oOperationIntervalEnd)) { return false; } } return true; }
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; }
function create_conference() { global $log, $spUser,$_POST,$data; $msgs = array(); // check the title if (!$_POST[conference_name] ) { $msgs[] = "Conference must have a title"; return $msgs ; } // validate the date ... if (($conference_uts = strtotime($_POST[conference_date]))===false ) { $msgs[] = "Conference date is an Invalid date."; return $msgs ; } list ($m,$d,$y) = split('-',$_POST[conference_date]); // Make date objects... $confDate = new Date(); $confDate->setMonth($m); $confDate->setYear($y); $confDate->setDay($d); $confDate->setHour(0); $confDate->setMinute(0); $confDate->setSecond(0); $beginTime = $confDate; $endTime = $confDate; list ($beginHour,$beginMinute) = split(':', $_POST[begin_time] ); list ($endHour,$endMinute) = split(':', $_POST[end_time] ); $beginTime->setHour($beginHour); $beginTime->setMinute($beginMinute); $endTime->setHour($endHour); $endTime->setMinute($endMinute); // see if it's the past if ($endTime->isPast() ){ $msgs[] = "Conference date is in the Past."; return $msgs ; } // Make sure the end time is not less than the begin time if (Date::compare($endTime, $beginTime) != 1 ){ $msgs[] = "Start time must be before end time."; return $msgs ; } // create a new Conference object $conference = new Conference($data->db, $spUser->username,$spUser->domain); // get the user's company Id and load the companies constraints $conference->getCompanyId(); $conference->loadConstraints() ; // set the date objects. $conference->conferenceDate = $confDate; $conference->beginTime = $beginTime; $conference->endTime = $endTime; $conference->conferenceName = $_POST[conference_name] ; // Is the conference too long if (!$conference->isMaxTime()) { $msgs[] = "Your conference exceeds the maximum amount of minutes."; return $msgs ; } // Are there other conferences scheduled for this time. if (!$conference->isMaxConcurrent()) { $msgs[] = "Your company has other conferences scheduled for this time."; return $msgs ; } $error = "nay!"; if ($conference->create($error) ) { $msgs[] = "Conference created id = " . $conference->conferenceId; Header("Location: conference.php?msg=Conference created ") ; } else { $msgs[] = "Failed to create conference. "; $msgs[] = "$error"; } $owner = new Invitee($data->db, $conference->conferenceId); $owner->domain = $spUser->domain; $owner->username = $spUser->username; $owner->companyId = $conference->companyId; $owner->inviteeEmail = $spUser->dbFields[email_address] ; $owner->ownerFlag = 1; $owner->inviteeName = $spUser->dbFields[first_name] . " " . $spUser->dbFields[last_name] ; // genereate that unique code $owner->generateInviteeCode(); $owner->create(); $owner->sendNotify(); return $msgs ; }
/** * Convert Date from iso 8601 format. * * @access private * * @param string $date date string in ISO 8601 format * @param PEAR::Date &$oResult transformed date * @param XML_RPC_Response &$oResponseWithError response with error message * * @return boolean shows true if method was executed successfully */ function _convertDateFromIso8601Format($date, &$oResult, &$oResponseWithError) { $datetime = explode('T', $date); $year = substr($datetime[0], 0, strlen($datetime[0]) - 4); $month = substr($datetime[0], -4, 2); $day = substr($datetime[0], -2, 2); // Explicitly allow the "zero date" value to be set if ($year == 0 && $month == 0 && $day == 0) { return new Date('0000-00-00'); } if ($year < 1970 || $year > 2038) { $oResponseWithError = XmlRpcUtils::generateError('Year should be in range 1970-2038'); return false; } elseif ($month < 1 || $month > 12) { $oResponseWithError = XmlRpcUtils::generateError('Month should be in range 1-12'); return false; } elseif ($day < 1 || $day > 31) { $oResponseWithError = XmlRpcUtils::generateError('Day should be in range 1-31'); return false; } else { $oResult = new Date(); $oResult->setYear($year); $oResult->setMonth($month); $oResult->setDay($day); return true; } }
function DaysNameofMonth($Month, $Year) { $date = new Date(); $Date_Calc = new Date_Calc(); $date->setYear($Year); $date->setMonth($Month); $NodaysMonth = $date->getDaysInMonth(); $firstDate = $Year . "-" . $Month . "-01"; $date->setDate($firstDate); $daysName = array(); for ($i = 0; $i < $NodaysMonth; $i++) { $daysName[$i] = $date->getDayName(True, 3); $getNextday = $date->getNextDay(); $date->setDate($getNextday); } return $daysName; }
/** * 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; } } } }
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()); }
function nombre_periodo($duracion_periodo_meses = 1, $numero_periodo = null, $anio = null) { $resultado = null; if (isset($anio)) { if ($duracion_periodo_meses == 1) { if ($numero_periodo) { $mi_date = new Date(); $mi_date->setMonth($numero_periodo); $mi_date->setYear($anio); $resultado = format_date($mi_date->getTimestamp(), 'MMMM yyyy'); } else { $resultado = $anio; } } else { $lista_posiciones = array('1' => __('primer'), '2' => __('segundo'), '3' => __('tercer'), '4' => __('cuarto'), '5' => __('quinto'), '6' => __('sexto')); $tipos_periodo = CampoPeer::getTiposPeriodo(); $periodo = __('%posicion% %periodo%', array('%posicion%' => isset($lista_posiciones[$numero_periodo]) ? $lista_posiciones[$numero_periodo] : '', '%periodo%' => isset($tipos_periodo[$duracion_periodo_meses]) ? $tipos_periodo[$duracion_periodo_meses] : '')); if (isset($numero_periodo) && $numero_periodo != '') { $resultado = __('%periodo% de %year%', array('%periodo%' => $periodo, '%year%' => $anio)); } else { $resultado = $anio; } } } return $resultado; }
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()); }
/** * Compares the given date and the current date. * * @return integer * @link http://www.php.net/manual/en/function.mktime.php */ function _compareGivenDateAndCurrentDate() { $givenDate = new Date(); $givenDate->setYear($this->_year); $givenDate->setMonth($this->_month); $givenDate->setDay($this->_day); $givenDate->setHour(0); $givenDate->setMinute(0); $givenDate->setSecond(0); $currentDate = new Date(); $currentDate->setHour(0); $currentDate->setMinute(0); $currentDate->setSecond(0); return @Date::compare($givenDate, $currentDate); }
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; } } }
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; }
public function getWeekOfYear() { $day = $this->day; $month = $this->month; $year = $this->year; $mnth = array (0,31,59,90,120,151,181,212,243,273,304,334); $y_isleap = $this->isLeapYear(); $d = new Date($this); $d->setYear($this->year - 1); $y_1_isleap = $d->isLeapYear(); $day_of_year_number = $day + $mnth[$month - 1]; if ($y_isleap && $month > 2) $day_of_year_number++; // find Jan 1 weekday (monday = 1, sunday = 7) $yy = ($year - 1) % 100; $c = ($year - 1) - $yy; $g = $yy + intval($yy/4); $jan1_weekday = 1 + intval((((($c / 100) % 4) * 5) + $g) % 7); // weekday for year-month-day $h = $day_of_year_number + ($jan1_weekday - 1); $weekday = 1 + intval(($h - 1) % 7); // find if Y M D falls in YearNumber Y-1, WeekNumber 52 or if ($day_of_year_number <= (8 - $jan1_weekday) && $jan1_weekday > 4) { $yearnumber = $year - 1; if ($jan1_weekday == 5 || ($jan1_weekday == 6 && $y_1_isleap)) $weeknumber = 53; else $weeknumber = 52; } else $yearnumber = $year; // find if Y M D falls in YearNumber Y+1, WeekNumber 1 if ($yearnumber == $year) { if ($y_isleap) $i = 366; else $i = 365; if (($i - $day_of_year_number) < (4 - $weekday)) { $yearnumber++; $weeknumber = 1; } } // find if Y M D falls in YearNumber Y, WeekNumber 1 through 53 if ($yearnumber == $year) { $j = $day_of_year_number + (7 - $weekday) + ($jan1_weekday - 1); $weeknumber = intval($j / 7); // kludge!!! - JMC if ($jan1_weekday > 4) $weeknumber--; } return $weeknumber; }
public static function createCalendarioMes($mes, $ano, $modo) { //include_once('CalendarShow.class.php'); $cal = new CalendarShow(); $fecha = new Date(); $fecha->setDay(1); $fecha->setMonth($mes); $fecha->setYear($ano); $fecha_uno = $fecha->toString(FMT_DATEMYSQL); $fecha->addMonths(1); $fecha->addDays(-1); $fecha_dos = $fecha->toString(FMT_DATEMYSQL); $diasEvento = array(); $diasTareas = array(); $c1 = TareaPeer::getCriterioAlcance(); $crit0 = $c1->getNewCriterion(TareaPeer::FECHA_INICIO, $fecha_uno . " 00:00:00", Criteria::GREATER_EQUAL); $crit1 = $c1->getNewCriterion(TareaPeer::FECHA_INICIO, $fecha_dos . " 23:59:59", Criteria::LESS_EQUAL); $crit0->addAnd($crit1); $crit2 = $c1->getNewCriterion(TareaPeer::FECHA_VENCIMIENTO, $fecha_uno . " 00:00:00", Criteria::GREATER_EQUAL); $crit3 = $c1->getNewCriterion(TareaPeer::FECHA_VENCIMIENTO, $fecha_dos . " 23:59:59", Criteria::LESS_EQUAL); $crit2->addAnd($crit3); $crit0->addOr($crit2); $c1->add($crit0); $c1->setDistinct(); $dias = TareaPeer::doSelect($c1); $ruta = UsuarioPeer::getRuta(); foreach ($dias as $dia) { $fecha_inicio = $dia->getFechaInicio('Y-m-d'); $fecha_fin = $dia->getFechaVencimiento('Y-m-d'); if ($fecha_inicio == $fecha_fin) { if ($dia->getEsEvento() == '1') { if (!isset($diasEvento[$fecha_inicio])) { $diasEvento[$fecha_inicio] = ""; } //$diasEvento[$fecha_inicio] .= "<div style=\"background-color: #4078B5; color: #ffffff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>"; $diasEvento[$fecha_inicio] .= $dia->getResumen(); } else { if (!isset($diasTareas[$fecha_inicio])) { $diasTareas[$fecha_inicio] = ""; } //$diasTareas[$fecha_inicio] .= "<div style=\"background-color: #76BB5F; color: #fff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>"; $diasTareas[$fecha_inicio] .= $dia->getResumen(); } } else { if ($dia->getEsEvento() == '1') { if (!isset($diasEvento[$fecha_inicio])) { $diasEvento[$fecha_inicio] = ""; } if (!isset($diasEvento[$fecha_fin])) { $diasEvento[$fecha_fin] = ""; } //$diasEvento[$fecha_inicio] .= "<div style=\"background-color: #4078B5; color: #ffffff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">Inicio Evento: ".$dia->getResumen()."</a></div>"; $diasEvento[$fecha_inicio] .= $dia->getResumen(); //$diasEvento[$fecha_fin] .= "<div style=\"background-color: #4078B5; color: #ffffff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">Vencimiento Evento: ".$dia->getResumen()."</a></div>"; $diasEvento[$fecha_fin] .= $dia->getResumen(); } else { if (!isset($diasTareas[$fecha_inicio])) { $diasTareas[$fecha_inicio] = ""; } if (!isset($diasTareas[$fecha_fin])) { $diasTareas[$fecha_fin] = ""; } //$diasTareas[$fecha_inicio] .= "<div style=\"background-color: #76BB5F; color: #fff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">Inicio Tarea: ".$dia->getResumen()."</a></div>"; $diasTareas[$fecha_inicio] .= $dia->getResumen(); //$diasTareas[$fecha_fin] .= "<div style=\"background-color: #76BB5F; color: #fff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">Vencimiento Tarea: ".$dia->getResumen()."</a></div>"; $diasTareas[$fecha_fin] .= $dia->getResumen(); } } /* if ($dia->getEsEvento() == '1') { if (isset($diasEvento[$fecha])) $diasEvento[$fecha] .= "<div style=\"background-color: #4078B5; color: #ffffff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>"; else $diasEvento[$fecha] = "<div style=\"background-color: #4078B5; color: #ffffff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>"; } else { if (isset($diasTareas[$fecha])) $diasTareas[$fecha] .= "<div style=\"background-color: #76BB5F; color: #fff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>"; else $diasTareas[$fecha] = "<div style=\"background-color: #76BB5F; color: #fff;\"><a href=\"".$ruta."/tareas/show/?id_tarea=".$dia->getIdTarea()."\" style=\"color: #ffffff;\">".$dia->getResumen()."</a></div>"; } */ $filters = array(); $filters['fecha_inicio']['from'] = $dia->getFechaInicio('d/m/Y'); $filters['fecha_inicio']['to'] = $dia->getFechaVencimiento('d/m/Y'); if ($modo) { if ($fecha_inicio != $fecha_fin) { $cal->setDateLink($fecha_inicio, "tareas/list?mes=" . $dia->getFechaInicio('m') . "&year=" . $dia->getFechaInicio('Y') . "&filters=" . $filters); $cal->setDateLink($fecha_fin, "tareas/list?mes=" . $dia->getFechaInicio('m') . "&year=" . $dia->getFechaInicio('Y') . "&filters=" . $filters); } else { $cal->setDateLink($fecha_inicio, "tareas/list?mes=" . $dia->getFechaInicio('m') . "&year=" . $dia->getFechaInicio('Y') . "&filters=" . $filters); } } else { if ($fecha_inicio != $fecha_fin) { $cal->setDateLink($fecha_inicio, "1"); $cal->setDateLink($fecha_fin, "1"); } else { $cal->setDateLink($fecha_inicio, "1"); } } } $cal->setDaysInColor($diasEvento); $cal->setDaysFree($diasTareas); return $cal; }
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; } }
function transferFormerFinishedTransactions($account) { global $us; if ($us->getProperty('autoExpandPlannedTransactions') == false) { return; } $now = new Date(); $now->setHour(0); $now->setMinute(0); $now->setSecond(0); $account->setType('planned'); $account->setFilter(array(array('key' => 'beginDate', 'op' => 'le', 'val' => $now))); try { $lastInsertDate = $us->getProperty('Account_' . $account->getId() . '_LastTransferFormerFinishedTransactions'); } catch (BadgerException $ex) { $lastInsertDate = new Date('1000-01-01'); } $us->setProperty('Account_' . $account->getId() . '_LastTransferFormerFinishedTransactions', $now); if (!$lastInsertDate->before($now)) { return; } while ($currentTransaction = $account->getNextPlannedTransaction()) { $date = new Date($currentTransaction->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 = $currentTransaction->getEndDate()) ? new Date('9999-12-31') : $tmp)) { if ($date->after($lastInsertDate)) { $account->addFinishedTransaction($currentTransaction->getAmount(), $currentTransaction->getTitle(), $currentTransaction->getDescription(), new Date($date), $currentTransaction->getTransactionPartner(), $currentTransaction->getCategory(), $currentTransaction->getOutsideCapital(), false, true); } //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; } } } }