Example #1
1
 public function __construct()
 {
     $this->TaxAmount = 0.0;
     $dateTime = new DateTime();
     $dateTime->setDate(1900, 01, 01);
     $this->TaxDate = $dateTime->format("Y-m-d");
 }
Example #2
0
	/**
	 * @param string $date String representation of date.
	 * @param string $format PHP date format. If not specified, the format is got from the current culture.
	 *
	 * @throws Main\ObjectException
	 */
	public function __construct($date = null, $format = null)
	{
		$this->value = new \DateTime();
		if ($date !== null && $date !== "")
		{
			if ($format === null)
			{
				$format = static::getFormat();
			}

			$parsedValue = date_parse_from_format($format, $date);
			//Ignore errors when format is longer than date
			//or date string is longer than format
			if ($parsedValue['error_count'] > 1)
			{
				if (
					current($parsedValue['errors']) !== 'Trailing data'
					&& current($parsedValue['errors']) !== 'Data missing'
				)
				{
					throw new Main\ObjectException("Incorrect date: ".$date);
				}
			}

			$this->value->setDate($parsedValue['year'], $parsedValue['month'], $parsedValue['day']);
		}
		$this->value->setTime(0, 0, 0);
	}
 public function __construct()
 {
     $dateTime = new DateTime();
     $dateTime->setDate(01, 01, 01);
     $this->FromDate = $dateTime->format("Y-m-d");
     $dateTime->setDate(01, 01, 01);
     $this->ToDate = $dateTime->format("Y-m-d");
 }
Example #4
0
 public function indexAction()
 {
     if ($this->apartmentStatus == Objects::PRODUCT_STATUS_DISABLED) {
         $this->redirect()->toRoute('apartment/general', ['apartment_id' => $this->apartmentId]);
     }
     /*
      * @todo move out this
      */
     $weekDays = array('Sunday' => 0, 'Monday' => 1, 'Tuesday' => 2, 'Wednesday' => 3, 'Thursday' => 4, 'Friday' => 5, 'Saturday' => 6);
     // get main params from route, month and year
     $year = $this->params()->fromRoute('year', 0);
     $month = $this->params()->fromRoute('month', 0);
     if ($year && $month) {
         // do checks for given month and year
         $roleManager = 'no';
         $auth = $this->getServiceLocator()->get('library_backoffice_auth');
         if ($auth->hasRole(Roles::ROLE_APARTMENT_INVENTORY_MANAGER)) {
             $roleManager = 'yes';
         }
         $givenMonthName = date("F", mktime(0, 0, 0, $month, 10));
         // get given month name
         $firstDayOfGivenMonthTimestamp = strtotime('first day of ' . $year . '-' . $month);
         // get first day of given month in miliseconds
         $firstDayOfGivenMonthDate = getdate($firstDayOfGivenMonthTimestamp);
         // get date array from timestamp
         $dayOfWeek = $weekDays[$firstDayOfGivenMonthDate['weekday']];
         // get day of week for given month first day to correctly render calendar
         $givenMonthDaysCount = cal_days_in_month(CAL_GREGORIAN, $month, $year);
         /** @var $rateService \DDD\Service\Apartment\Rate */
         $rateService = $this->getServiceLocator()->get('service_apartment_rate');
         $rates = $rateService->getApartmentRates($this->apartmentId);
         // building inventory array
         $inventory = array();
         foreach ($rates as $rate) {
             $rateID = $rate->getID();
             $rateAvailability = $rateService->getRateAvailabilityForMonth($rateID, $year, $month);
             foreach ($rateAvailability as $singleDayAvailability) {
                 $inventory[$rateID][$singleDayAvailability->getDate()] = ["availability" => $singleDayAvailability->getAvailability(), "price" => $singleDayAvailability->getPrice(), "isLockPrice" => $singleDayAvailability->getIsLockPrice()];
             }
         }
         $detailsDao = $this->getServiceLocator()->get('dao_apartment_details');
         $apartmentDetails = $detailsDao->fetchOne(['apartment_id' => $this->apartmentId], ['sync_cubilis']);
         $isConnected = $apartmentDetails->getSync_cubilis();
         $urlToggleAvailability = $this->url()->fromRoute('apartment/calendar/toggle-availability', ['apartment_id' => $this->apartmentId, 'year' => date('Y'), 'month' => date('m')]);
         $urlUpdatePrices = $this->url()->fromRoute('apartment/calendar/update-prices', ['apartment_id' => $this->apartmentId, 'year' => date('Y'), 'month' => date('m')]);
         $date = new \DateTime();
         $date->setDate($year, $month, 1);
         $monthStart = $date->format('Y-m-d');
         if ($monthStart < date('Y-m-d', strtotime('-1 days'))) {
             $monthStart = date('Y-m-d', strtotime('-1 days'));
         }
         $date->setDate($year, $month, $givenMonthDaysCount);
         $monthEnd = $date->format('Y-m-d');
         return new ViewModel(['apartmentId' => $this->apartmentId, 'apartmentStatus' => $this->apartmentStatus, 'year' => $year, 'month' => $month, 'givenMonthName' => $givenMonthName, 'givenMonthDaysCount' => $givenMonthDaysCount, 'dayOfWeek' => $dayOfWeek, 'rates' => $rates, 'inventory' => $inventory, 'urlToggleAvailability' => $urlToggleAvailability, 'urlUpdatePrices' => $urlUpdatePrices, 'roleManager' => $roleManager, 'monthStart' => $monthStart, 'monthEnd' => $monthEnd, 'isConnected' => $isConnected]);
     } else {
         return $this->redirect()->toRoute('apartment/calendar', ["year" => date('Y'), "month" => date('m')], [], true);
     }
 }
 public function __construct()
 {
     $this->RequestStatus = CertificateRequestStatus::$ALL;
     $dateTime = new DateTime();
     $dateTime->setDate(01, 01, 01);
     $this->ModFromDate = $dateTime->format("Y-m-d");
     $dateTime->setDate(01, 01, 01);
     $this->ModToDate = $dateTime->format("Y-m-d");
 }
Example #6
0
 public function increment(\DateTime $date, $invert = false)
 {
     if (${${"GLOBALS"}["icdiaipis"]}) {
         $date->modify("-1 year");
         $date->setDate($date->format("Y"), 12, 31);
         $date->setTime(23, 59, 0);
     } else {
         $date->modify("+1 year");
         $date->setDate($date->format("Y"), 1, 1);
         $date->setTime(0, 0, 0);
     }
     return $this;
 }
Example #7
0
 public function increment(\DateTime $date, $invert = false)
 {
     if ($invert) {
         $date->modify('-1 year');
         $date->setDate($date->format('Y'), 12, 31);
         $date->setTime(23, 59, 0);
     } else {
         $date->modify('+1 year');
         $date->setDate($date->format('Y'), 1, 1);
         $date->setTime(0, 0, 0);
     }
     return $this;
 }
Example #8
0
 public function generateIdentification(InvoiceEntity $invoiceEntity)
 {
     $date = new \DateTime();
     $account = $invoiceEntity->getSupplier();
     $format = $account->getIdentificationFormat();
     $dateFrom = new \DateTime();
     if ($account->getIdentificationInterval() === AccountEntity::INTERVAL_YEAR) {
         $dateFrom->setTime(0, 0, 0);
         $dateFrom->setDate($dateFrom->format('Y'), 1, 1);
         $dateTo = \DateTime::createFromFormat('Y-m-d', intval($dateFrom->format('Y')) + 1 . '-01-01');
         $dateTo->setTime(0, 0, 0);
     } elseif ($account->getIdentificationInterval() === AccountEntity::INTERVAL_MONTH) {
         $dateFrom->setTime(0, 0, 0);
         $dateFrom->setDate($dateFrom->format('Y'), $dateFrom->format('m'), 1);
         $year = intval($dateFrom->format('Y'));
         $month = intval($dateFrom->format('m')) + 1;
         if ($month > 12) {
             $month = $month - 12;
             $year++;
         }
         $dateTo = \DateTime::createFromFormat('Y-m-d', $year . '-' . $month . '-01');
         $dateTo->setTime(0, 0, 0);
     } elseif ($account->getIdentificationInterval() === AccountEntity::INTERVAL_QUARTER) {
         $month = intval($dateFrom->format('m'));
         $year = intval($dateFrom->format('Y'));
         $dateFrom->setTime(0, 0, 0);
         $dateFrom->setDate($year, $month % 4 * 4, 0);
         $month = $month + 4;
         if ($month > 12) {
             $month = $month - 12;
             $year++;
         }
         $dateTo = \DateTime::createFromFormat('Y-m-d', $year . '-' . $month % 4 * 4 . '-01');
         $dateTo->setTime(0, 0, 0);
     }
     $qb = $this->invoiceRepository->createQueryBuilder('a')->select('COUNT(a.id)')->andWhere('a.identification IS NOT NULL')->andWhere('a.supplier = :supplier')->setParameter('supplier', $account->id);
     if (isset($dateTo)) {
         $qb = $qb->andWhere('a.date >= :dateFrom')->setParameter('dateFrom', $dateFrom)->andWhere('a.date < :dateTo')->setParameter('dateTo', $dateTo);
     }
     $identification = intval($qb->getQuery()->getSingleScalarResult()) + 1;
     if (preg_match_all('/\\?(\\d+)/is', $format, $matches)) {
         $number = $matches[1][0];
         $format = str_replace('?' . $number, sprintf('%0' . $number . 'd', $identification), $format);
     }
     $exDate = clone $date;
     $exDate->modify('+' . $account->getDue() . ' days');
     $invoiceEntity->setDate($date);
     $invoiceEntity->setExpirationDate($exDate);
     $invoiceEntity->setIdentification($date->format($format));
     $this->invoiceRepository->save($invoiceEntity);
 }
Example #9
0
 public function indexAction()
 {
     /**
      * @var \DDD\Service\Parking\Spot $parkingSpotService
      * @var \DDD\Service\Parking\Spot\Inventory $spotInventoryService
      */
     $parkingSpotService = $this->getServiceLocator()->get('service_parking_spot');
     $spotInventoryService = $this->getServiceLocator()->get('service_parking_spot_inventory');
     /*
      * @todo move out this
      */
     $weekDays = array('Sunday' => 0, 'Monday' => 1, 'Tuesday' => 2, 'Wednesday' => 3, 'Thursday' => 4, 'Friday' => 5, 'Saturday' => 6);
     // get main params from route, month and year
     $year = $this->params()->fromRoute('year', 0);
     $month = $this->params()->fromRoute('month', 0);
     if ($year && $month) {
         $givenMonthName = date("F", mktime(0, 0, 0, $month, 10));
         // get given month name
         // get first day of given month in miliseconds
         $firstDayOfGivenMonthTimestamp = strtotime('first day of ' . $year . '-' . $month);
         // get date array from timestamp
         $firstDayOfGivenMonthDate = getdate($firstDayOfGivenMonthTimestamp);
         // get day of week for given month first day to correctly render calendar
         $dayOfWeek = $weekDays[$firstDayOfGivenMonthDate['weekday']];
         $givenMonthDaysCount = cal_days_in_month(CAL_GREGORIAN, $month, $year);
         $spots = $parkingSpotService->getParkingSpots($this->parkingLotId)->buffer();
         // building inventory array
         $inventory = [];
         foreach ($spots as $spot) {
             $spotId = $spot->getId();
             $spotAvailability = $spotInventoryService->getSpotAvailabilityForMonth($spotId, $year, $month);
             foreach ($spotAvailability as $singleDayAvailability) {
                 $inventory[$spotId][$singleDayAvailability->getDate()] = ["availability" => $singleDayAvailability->getAvailability(), "price" => $singleDayAvailability->getPrice()];
             }
         }
         $urlUpdateAvailabilities = $this->url()->fromRoute('parking/calendar/update-availabilities', ['parking_lot_id' => $this->parkingLotId, 'year' => date('Y'), 'month' => date('m')]);
         $date = new \DateTime();
         $date->setDate($year, $month, 1);
         $monthStart = $date->format('Y-m-d');
         if ($monthStart < date('Y-m-d', strtotime('-1 days'))) {
             $monthStart = date('Y-m-d', strtotime('-1 days'));
         }
         $date->setDate($year, $month, $givenMonthDaysCount);
         $monthEnd = $date->format('Y-m-d');
         return new ViewModel(['parkingLotId' => $this->parkingLotId, 'year' => $year, 'month' => $month, 'givenMonthName' => $givenMonthName, 'givenMonthDaysCount' => $givenMonthDaysCount, 'dayOfWeek' => $dayOfWeek, 'spots' => $spots, 'inventory' => $inventory, 'urlUpdateAvailabilities' => $urlUpdateAvailabilities, 'monthStart' => $monthStart, 'monthEnd' => $monthEnd]);
     } else {
         return $this->redirect()->toRoute('parking/calendar', ["year" => date('Y'), "month" => date('m')], [], true);
     }
 }
Example #10
0
function getDateTimeFromDateBd($data)
{
    list($ano, $mes, $dia) = explode("-", $data);
    $ret = new DateTime();
    $ret->setDate($ano, $mes, $dia);
    return $ret;
}
 /**
  * Création d'arbitres dans la base de données
  */
 public function run()
 {
     DB::table('arbitre_epreuve')->delete();
     DB::table("arbitres")->delete();
     $epreuves = Epreuve::all();
     $entrees = [["Benoit", "Desrosiers", "1", "AQSFR", "819-578-6489", 0], ["Guy", "Bernard", "1", "OSQ", "450-715-6915", 0], ["Jonathan", "Gareau", "1", "ASSQ", "514-763-2485", 0], ["Stéphane", "Janvier", "2", "ASAQ", "450-571-1203", 0]];
     $regions = Region::all();
     foreach ($entrees as $entree) {
         $arbitre = new Arbitre();
         $arbitre->prenom = $entree[0];
         $arbitre->nom = $entree[1];
         $arbitre->region_id = $regions->random()->id;
         $arbitre->numero_accreditation = $entree[2];
         $arbitre->association = $entree[3];
         $arbitre->numero_telephone = $entree[4];
         $arbitre->sexe = $entree[5];
         $date_temp = new DateTime();
         $date_temp->setDate(1994, 1, 1);
         $arbitre->date_naissance = $date_temp;
         $arbitre->save();
         for ($j = 0; $j < rand(1, 4); $j++) {
             $epreuves->random()->arbitres()->attach($arbitre->id);
         }
     }
 }
 public function mock($year = 2012, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0)
 {
     $dt = new \DateTime('', new \DateTimeZone('UTC'));
     $dt->setTime($hour, $minute, $second);
     $dt->setDate($year, $month, $day);
     $this->now = $dt->getTimestamp();
 }
 public static function getEvents(eZContentObjectTreeNode $node, array $parameters)
 {
     $events = array();
     $base = array('name' => $node->attribute('name'), 'main_node_id' => $node->attribute('main_node_id'), 'main_url_alias' => $node->attribute('url_alias'), 'fields' => array('attr_from_time_dt' => 0, 'attr_to_time_dt' => 0));
     try {
         $startDate = new DateTime('now', OCCalendarData::timezone());
         $startDate->setDate(date('Y', $parameters['search_from_timestamp']), date('n', $parameters['search_from_timestamp']), date('j', $parameters['search_from_timestamp']));
         $endDate = clone $startDate;
         $endDate->add(new DateInterval($parameters['interval']));
         $byDayInterval = new DateInterval('P1D');
         /** @var DateTime[] $byDayPeriod */
         $byDayPeriod = new DatePeriod($startDate, $byDayInterval, $endDate);
         $timeTable = self::getTimeTableFromNode($node);
         foreach ($byDayPeriod as $date) {
             $weekDay = $date->format('w');
             if (isset($timeTable[$weekDay])) {
                 foreach ($timeTable[$weekDay] as $value) {
                     $newEvent = $base;
                     $date->setTime($value['from_time']['hour'], $value['from_time']['minute']);
                     $newEvent['fields']['attr_from_time_dt'] = $date->format('Y-m-d\\TH:i:s\\Z');
                     $date->setTime($value['to_time']['hour'], $value['to_time']['minute']);
                     $newEvent['fields']['attr_to_time_dt'] = $date->format('Y-m-d\\TH:i:s\\Z');
                     $item = OCCalendarItem::fromEzfindResultArray($newEvent);
                     $events[] = $item;
                 }
             }
         }
     } catch (Exception $e) {
         eZDebug::writeError($e->getMessage(), __METHOD__);
     }
     return $events;
 }
Example #14
0
 public function getValue()
 {
     if ($this->_get('value_datetime')) {
         if ($this->_get('value')) {
             if ('0000-00-00 00:00:00' === $this->_get('value_datetime')) {
                 return null;
             }
             $obj = new DateTime($this->_get('value_datetime'));
             return $obj->format('Y-m-d');
         }
         return null;
     }
     if ($this->getProfile()->isPreset()) {
         if ('op_preset_birthday' === $this->getProfile()->getName()) {
             return null;
         }
         return $this->_get('value');
     } elseif ('date' !== $this->getFormType() && $this->getProfileOptionId()) {
         return $this->getProfileOptionId();
     }
     $children = $this->getChildrenValues();
     if ($children) {
         if ('date' === $this->getFormType()) {
             if (count($children) == 3 && $children[0] && $children[1] && $children[2]) {
                 $obj = new DateTime();
                 $obj->setDate($children[0], $children[1], $children[2]);
                 return $obj->format('Y-m-d');
             }
             return null;
         }
         return $children;
     }
     return parent::rawGet('value');
 }
Example #15
0
 public function indexAction()
 {
     $em = $this->EntityPlugin()->getEntityManager();
     $auth = $this->getServiceLocator()->get('Zend\\Authentication\\AuthenticationService');
     $user = $auth->getIdentity();
     $year = $this->params()->fromRoute('year');
     $date = new \DateTime();
     if (!empty($year)) {
         $date->setDate($year, 1, 1);
     }
     $operationsSummaryIncome = $em->getRepository('HouseholdBudget\\Entity\\Operation')->getMonthlySummaryByType($user->getId(), 'income', $date->format('Y'));
     $operationsSummaryExpense = $em->getRepository('HouseholdBudget\\Entity\\Operation')->getMonthlySummaryByType($user->getId(), 'expense', $date->format('Y'));
     $highestIncome = 0;
     foreach ($operationsSummaryIncome as $income) {
         if ($highestIncome < $income['total']) {
             $highestIncome = $income['total'];
         }
     }
     $highestExpense = 0;
     foreach ($operationsSummaryExpense as $expense) {
         if ($highestExpense < $expense['total']) {
             $highestExpense = $expense['total'];
         }
     }
     echo '<pre>';
     //        echo var_dump($operationsSummaryIncome);
     //        echo var_dump($operationsSummaryExpense);
     echo '</pre>';
     return new ViewModel(array('operationsSummaryIncome' => $operationsSummaryIncome, 'operationsSummaryExpense' => $operationsSummaryExpense, 'highestValue' => $highestIncome > $highestExpense ? $highestIncome : $highestExpense, 'date' => $date));
 }
Example #16
0
 public function altaSerologia()
 {
     //echo 'se carga una serologia';
     //fecha de extraccion
     $fechaArray = explode('/', $this->input->post("fechaex"));
     $date = new DateTime();
     $date->setDate($fechaArray[2], $fechaArray[1], $fechaArray[0]);
     $fecha = $date->format('Y-m-d');
     //fin fecha de extracción
     // Fecha Carga
     $fechaArray = explode('/', $this->input->post("fechacar"));
     $date = new DateTime();
     $date->setDate($fechaArray[2], $fechaArray[1], $fechaArray[0]);
     $fechaCar = $date->format('Y-m-d');
     //fin fecha carga
     $unaSerologia = array('Consentimiento_nroConsentimiento' => $this->input->post("nroConsentimiento"), 'fechaSerologia' => $fecha, 'fechaCarga' => $fechaCar, 'vdrl' => $this->input->post("opcion1"), 'chagas' => $this->input->post("opcion2"), 'hvc' => $this->input->post("opcion3"), 'hiv' => $this->input->post("opcion4"), 'hvb' => $this->input->post("opcion5"), 'hvbCore' => $this->input->post("opcion6"), 'htlvl_ll' => $this->input->post("opcion7"), 'medicacion' => $this->input->post("opcion8"), 'fuma' => $this->input->post("opcion9"), 'droga' => $this->input->post("droga"), 'dosis' => $this->input->post("dosis"), 'alcohol' => $this->input->post("opcion10"), 'zonaRural' => $this->input->post("opcion11"), 'vacunas' => $this->input->post("opcion12"), 'usaDrogas' => $this->input->post("opcion13"), 'toxoplasmosis' => $this->input->post("opcion14"), 'igM' => $this->input->post("igm"), 'igG' => $this->input->post("igg"), 'observaciones' => $this->input->post("txtsugerencias"), 'estadoSerologia' => $this->input->post("opcion15"));
     $data['title'] = ucfirst("home");
     $idDonante = $this->serologia_model->insertNewserologia($unaSerologia);
     if ($idDonante == 0) {
         # code...
         echo "algo de error";
     } else {
         # code...
         redirect('cserologia/view/verSerologias/', 'refresh');
     }
     $consentimiento = $this->consentimiento_model->getConsentimiento($this->input->post("nroConsentimiento"));
     $solicitud = $consentimiento->solicitudSerologia;
     if ($solicitud == "0") {
         $unConsentimientoArreglado = array('solicitudSerologia' => '1');
         $this->consentimiento_model->updateConsentimiento($unConsentimientoArreglado, $this->input->post("nroConsentimiento"));
     }
 }
Example #17
0
function addToMixesLoadedTable($loadedMixesTitle, $sqlconn)
{
    $ip = $_SERVER['REMOTE_ADDR'];
    $loadedMixesTitle = str_replace("'", "\\'", $loadedMixesTitle);
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM Mixes WHERE MixName = '{$loadedMixesTitle}'", 'Mixes');
    $mixid = getMixId($res);
    $now = getdate(date("U"));
    $datetime = new DateTime();
    $datetime->setDate($now['year'], $now['mon'], $now['mday']);
    $datetime->setTime($now['hours'], $now['minutes'] - 5, $now['seconds']);
    $thetimestamp = $datetime->format('Y/m/d H:i:s');
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM MixesLoaded WHERE IpAddress = '{$ip}' AND DateTime > '{$thetimestamp}' AND MixId = '{$mixid}'", 'MixesLoaded');
    $mixid2 = getMixId($res);
    if ($mixid2 == '') {
        $table = 'MixesLoaded';
        $queryType = 'Insert';
        $condition = null;
        $types = array('text', 'integer');
        $columns = array('IpAddress', 'MixId');
        $values = array($ip, $mixid);
        $args = array('column' => $columns, 'value' => $values, 'type' => $types);
        $xml2 = createXML($table, $args);
        $res = $sqlconn->query($xml2, $queryType, $condition);
    }
}
/**
 * Formats date using current date format.
 *
 * @param Date $date in YYYY-MM-DD format
 * @return formatted date.
 */
function set_datepicker_date_format($date)
{
    if (sfContext::hasInstance()) {
        $dateFormat = sfContext::getInstance()->getUser()->getDateFormat();
    } else {
        $configService = new ConfigService();
        $dateFormat = $configService->getAdminLocalizationDefaultDateFormat();
    }
    if (empty($date)) {
        $formattedDate = null;
    } else {
        $dateArray = explode('-', $date);
        $dateTime = new DateTime();
        $year = $dateArray[0];
        $month = $dateArray[1];
        $day = $dateArray[2];
        // For timestamp fields, clean time part from $day (day will look like "21 00:00:00"
        $day = trim($day);
        $spacePos = strpos($day, ' ');
        if ($spacePos !== FALSE) {
            $day = substr($day, 0, $spacePos);
        }
        $dateTime->setDate($year, $month, $day);
        $formattedDate = $dateTime->format($dateFormat);
    }
    return $formattedDate;
}
Example #19
0
 /**
  * Resets the current time of the DateTime object to a different time.
  *
  * @param integer $year     Year of the date.
  * @param integer $month    Month of the date.
  * @param integer $day      Day of the date.
  * @return KDate or FALSE on failure.
  */
 public function setDate($year, $month, $day)
 {
     if ($this->_date->setDate($year, $month, $day) === false) {
         return false;
     }
     return $this;
 }
 /**
  * GET last 5 updated pages
  */
 public function searchArticles($lang, $slug, $isActive, $deleted)
 {
     $currentYear = new \DateTime();
     $currentYear->setDate(date('Y'), 1, 1)->setTime(0, 0, 0);
     $query = $this->createQueryBuilder('a')->where('a.isActive = :isActive')->andWhere('a.deleted = :deleted')->andWhere('a.content LIKE :slug')->orWhere('a.title LIKE :slug')->setParameter('isActive', $isActive)->setParameter('deleted', $deleted)->setParameter('slug', '%' . $slug . '%')->orderBy('a.date', 'DESC')->getQuery();
     return $query->getResult();
 }
Example #21
0
 /**
  * Converts Day object to DateTime object
  * @param integer $year
  * @return \DateTime
  */
 public function toDateTime($year)
 {
     $dt = new \DateTime();
     $dt->setDate($year, $this->getMonth(), $this->getDay());
     $dt->setTime(0, 0, 0);
     return $dt;
 }
 public function convertPHPFormatDateToISOFormatDate($inputPHPFormat, $date)
 {
     $dateFormat = new sfDateFormat();
     try {
         $symfonyPattern = $this->__getSymfonyDateFormatPattern($inputPHPFormat);
         $dateParts = $dateFormat->getDate($date, $symfonyPattern);
         if (is_array($dateParts) && isset($dateParts['year']) && isset($dateParts['mon']) && isset($dateParts['mday'])) {
             $day = $dateParts['mday'];
             $month = $dateParts['mon'];
             $year = $dateParts['year'];
             // Additional check done for 3 digit years, or more than 4 digit years
             if (checkdate($month, $day, $year) && $year >= 1000 && $year <= 9999) {
                 $dateTime = new DateTime();
                 $dateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
                 $dateTime->setDate($year, $month, $day);
                 $date = $dateTime->format('Y-m-d');
                 return $date;
             } else {
                 return "Invalid date";
             }
         }
     } catch (Exception $e) {
         return "Invalid date";
     }
     return null;
 }
 public function mktime($year = 2012, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0)
 {
     $dt = new \DateTime('', new \DateTimeZone('UTC'));
     $dt->setTime($hour, $minute, $second);
     $dt->setDate($year, $month, $day);
     return $dt;
 }
Example #24
0
function loadMetadata($crawler)
{
    $nameElement = $crawler->filter('#right')->first();
    if ($nameElement == NULL) {
        return NULL;
    }
    $name = $nameElement->text();
    $dateElement = $crawler->filter('#date')->first();
    if ($dateElement == NULL) {
        return NULL;
    }
    $dateString = $dateElement->text();
    $components = explode(' ', $dateString);
    $dateComponents = explode('.', end($components));
    $date = $dateComponents[2] . '-' . $dateComponents[1] . '-' . $dateComponents[0];
    $lastUpdateElement = $crawler->filter('#stand')->first();
    if ($lastUpdateElement == NULL) {
        return NULL;
    }
    $lastUpdateString = $lastUpdateElement->text();
    $components = explode(' ', $lastUpdateString);
    $dateComponents = explode('.', $components[2]);
    $timeComponents = explode(':', $components[3]);
    $day = intval($dateComponents[0]);
    $month = intval($dateComponents[1]);
    $year = intval($dateComponents[2]);
    $hour = intval($timeComponents[0]);
    $minute = intval($timeComponents[1]);
    $second = intval($timeComponents[2]);
    $lastUpdate = new DateTime();
    $lastUpdate->setDate($year, $month, $day);
    $lastUpdate->setTime($hour, $minute, $second);
    return array('name' => $name, 'date' => $date, 'lastUpdate' => $lastUpdate->format(DateTime::ATOM));
}
 public function testDateToSevenDate()
 {
     $date = new DateTime();
     $date->setDate(1959, 6, 2);
     $sd = new SevenDateConversion();
     $this->assertEquals(1, $sd->dateToSevenDate($date));
 }
Example #26
0
 public function testFromNativeDateTime()
 {
     $nativeDateTime = new \DateTime();
     $nativeDateTime->setDate(2013, 12, 14);
     $weekDay = WeekDay::fromNativeDateTime($nativeDateTime);
     $this->assertEquals('Saturday', $weekDay->toNative());
 }
 function setFilteredResults()
 {
     $this->queryBuilder = $this->doctrine->getEntityManager()->createQueryBuilder();
     $this->queryBuilder->select('a, b')->from('HelperBundle:FeedbackMessage', 'a')->leftJoin('a.country', 'b');
     if ($this->queryParams['keyword']) {
         $this->queryBuilder->where('a.name LIKE :searchKey OR a.emailAddress LIKE :searchKey OR a.message LIKE :searchKey');
         $this->queryBuilder->setParameter('searchKey', '%' . $this->queryParams['keyword'] . '%');
     }
     if ($this->queryParams['country'] != self::FILTER_KEY_ALL) {
         $this->queryBuilder->where('a.country = :country');
         $this->queryBuilder->setParameter('country', $this->queryParams['country']);
     }
     if ($this->queryParams['dateCreated']) {
         list($year, $month, $day) = explode('-', $this->queryParams['dateCreated']);
         $dateFrom = new \DateTime();
         $dateFrom->setDate($year, $month, $day);
         $dateFrom->setTime('00', '00', '00');
         $dateTo = clone $dateFrom;
         $dateTo->setTime('23', '59', '59');
         $this->queryBuilder->andWhere('a.dateCreated >= :dateFrom AND a.dateCreated <= :dateTo');
         $this->queryBuilder->setParameter('dateFrom', $dateFrom)->setParameter('dateTo', $dateTo);
     }
     $sortBy = $this->sortBy ? $this->sortBy : 'dateCreated';
     $sort = "a.{$sortBy} " . $this->sortOrder;
     $this->queryBuilder->add('orderBy', $sort);
     $this->pagerAdapter->setQueryBuilder($this->queryBuilder);
     //echo $this->queryBuilder->getQuery()->getSQL(); exit;
     $this->filteredResult = $this->pager->getResults();
 }
Example #28
0
 function _make_date($year, $month, $day = 1)
 {
     $date = new DateTime();
     $date->setDate($year, $month, $day);
     $date->setTime(0, 0, 0);
     return $date;
 }
Example #29
0
 public function testFromNativeDateTime()
 {
     $nativeDateTime = new \DateTime();
     $nativeDateTime->setDate(2013, 12, 1);
     $month = Month::fromNativeDateTime($nativeDateTime);
     $this->assertEquals('December', $month->toNative());
 }
Example #30
0
function getDefaultDate()
{
	$dateTime=new DateTime();
    $dateTime->setDate(1900,01,01);
    
    return $dateTime->format("Y-m-d");
}