コード例 #1
0
ファイル: AccountEntity.php プロジェクト: svobodni/web
 public function __construct()
 {
     $this->payments = new ArrayCollection();
     $this->syncDate = new \DateTime();
     $this->syncDate->modify('-3 years');
     $this->setOptions(array());
 }
コード例 #2
0
ファイル: Update20150228140410.php プロジェクト: mheydt/scalr
 protected function run1($stage)
 {
     $stmt = '';
     if (!$this->hasTableColumn('os', 'created')) {
         $bCreated = true;
         $this->console->out("Adding scalr.os.created column...");
         $stmt .= ", ADD COLUMN `created` DATETIME NOT NULL COMMENT 'Created at timestamp' AFTER `is_system`";
     }
     if (!$this->hasTableIndex('os', 'idx_created')) {
         $this->console->out("Adding idx_created index for scalr.os.created column...");
         $stmt .= ", ADD INDEX `idx_created` (`created` ASC)";
     }
     if (!empty($stmt)) {
         $this->db->Execute("ALTER TABLE `os` " . ltrim($stmt, ','));
     }
     if (!empty($bCreated)) {
         $date = new \DateTime();
         $date->modify('-1 hour');
         $list = Os::find([['$or' => [['created' => null], ['created' => new \DateTime('0000-00-00 00:00:00')]]]]);
         foreach ($list as $os) {
             /* @var $os Os */
             $os->created = $date;
             $os->save();
             $date->modify('+1 second');
         }
     }
 }
コード例 #3
0
 public function setDefaultValues()
 {
     $defaults = array();
     try {
         $defaults['rood_mtype'] = civicrm_api3('MembershipType', 'getvalue', array('return' => 'id', 'name' => 'Lid SP en ROOD'));
     } catch (Exception $e) {
         //do nothing
     }
     try {
         $defaults['rood_mstatus'] = civicrm_api3('MembershipStatus', 'getvalue', array('return' => 'id', 'name' => 'Correctie'));
     } catch (Exception $e) {
         //do nothing
     }
     try {
         $defaults['sp_mtype'] = civicrm_api3('MembershipType', 'getvalue', array('return' => 'id', 'name' => 'Lid SP'));
     } catch (Exception $e) {
         //do nothing
     }
     try {
         $status = civicrm_api3('MembershipStatus', 'getvalue', array('return' => 'id', 'name' => 'current'));
         $defaults['member_status_id'][$status] = $status;
     } catch (Exception $e) {
         //do nothing
     }
     $date = new DateTime();
     $date->modify('-26 years');
     $date->modify('first day of this year');
     list($defaults['birth_date_from']) = CRM_Utils_Date::setDateDefaults($date->format('Y-m-d'));
     $date->modify('last day of this year');
     list($defaults['birth_date_to']) = CRM_Utils_Date::setDateDefaults($date->format('Y-m-d'));
     $minimum_fee = CRM_Core_BAO_Setting::getItem('nl.sp.rood', 'minimum_fee', null, '5.00');
     $defaults['minimum_fee'] = $minimum_fee;
     return $defaults;
 }
コード例 #4
0
ファイル: MY_date.php プロジェクト: anqqa/Anqh
 /**
  * Returns date range Y-m-d - Y-m-d
  *
  * @param	 DateTime	$date
  * @param	 string	  $type (day, week, month)
  * @return array
  */
 public static function datetime2range(DateTime $date, $type)
 {
     switch ($type) {
         case 'day':
             $from = $to = $date->format('Y-m-d');
             break;
         case 'week':
             $fdow = Kohana::config('locale.start_monday') ? 1 : 7;
             $dow = $date->format('N');
             if ($dow > $fdow) {
                 $date->modify('-' . ($dow - $fdow) . ' days');
             }
         case '7days':
             $from = $date->format('Y-m-d');
             $date->modify('+6 days');
             $to = $date->format('Y-m-d');
             break;
         case 'month':
             $from = $date->format('Y-m-01');
             $to = $date->format('Y-m-t');
             break;
         default:
             return false;
     }
     return date::range($from, $to);
 }
コード例 #5
0
 public function get_schedule($id, $module)
 {
     $date = new DateTime(phpgw::get_var('date'));
     // Make sure $from is a monday
     if ($date->format('w') != 1) {
         $date->modify('last monday');
     }
     $prev_date = clone $date;
     $next_date = clone $date;
     $prev_date->modify('-1 week');
     $next_date->modify('+1 week');
     $building = $this->read_single($id);
     $building['buildings_link'] = self::link(array('menuaction' => $module . '.index'));
     $building['building_link'] = self::link(array('menuaction' => $module . '.show', 'id' => $building['id']));
     $building['date'] = $date->format('Y-m-d');
     $building['week'] = intval($date->format('W'));
     $building['year'] = intval($date->format('Y'));
     $building['prev_link'] = self::link(array('menuaction' => $module . '.schedule', 'id' => $building['id'], 'date' => $prev_date->format('Y-m-d')));
     $building['next_link'] = self::link(array('menuaction' => $module . '.schedule', 'id' => $building['id'], 'date' => $next_date->format('Y-m-d')));
     for ($i = 0; $i < 7; $i++) {
         $building['days'][] = array('label' => sprintf('%s<br/>%s %s', lang($date->format('l')), lang($date->format('M')), $date->format('d')), 'key' => $date->format('D'));
         $date->modify('+1 day');
     }
     return $building;
 }
コード例 #6
0
ファイル: Date.php プロジェクト: Bergdahls/YetiForceCRM
 function getValue($fieldName, $relId, $templateId, $baseRecord = NULL, $partentTplId = NULL)
 {
     $val = parent::getValue($fieldName, $relId, $templateId, $baseRecord, $partentTplId);
     if ('create_date' === $val) {
         return date('Y-m-d');
     } else {
         if ('num_day' === $val) {
             $db = PearDatabase::getInstance();
             $dayFielddName = $fieldName . '_day';
             if (NULL !== $baseRecord && NULL !== $partentTplId) {
                 $templateId = $partentTplId;
             }
             $numDaySql = "SELECT fld_val FROM vtiger_oss_project_templates WHERE fld_name = ? AND id_tpl = ?";
             $numDayResult = $db->pquery($numDaySql, array($dayFielddName, $templateId), true);
             $numDay = $db->query_result($numDayResult, 0, 'fld_val');
             $typeFielddName = $fieldName . '_day_type';
             $onlyBusinessDaySql = "SELECT fld_val FROM vtiger_oss_project_templates WHERE fld_name = ? AND id_tpl = ? ";
             $onlyBusinessDayResult = $db->pquery($onlyBusinessDaySql, array($typeFielddName, $templateId), TRUE);
             $dayType = $db->query_result($onlyBusinessDayResult, 0, 'fld_val');
             $date = new DateTime();
             if (!!$dayType) {
                 $date->modify("+ {$numDay} weekdays");
             } else {
                 $date->modify("+ {$numDay} days");
             }
             return $date->format('Y-m-d');
         } else {
             return '';
         }
     }
 }
コード例 #7
0
ファイル: MinutesField.php プロジェクト: alvarobfdev/applog
 public function increment(\DateTime $date, $invert = false, $parts = null)
 {
     if (is_null($parts)) {
         if ($invert) {
             $date->modify('-1 minute');
         } else {
             $date->modify('+1 minute');
         }
         return $this;
     }
     $parts = strpos($parts, ',') !== false ? explode(',', $parts) : array($parts);
     $minutes = array();
     foreach ($parts as $part) {
         $minutes = array_merge($minutes, $this->getRangeForExpression($part, 59));
     }
     $current_minute = $date->format('i');
     $position = $invert ? count($minutes) - 1 : 0;
     if (count($minutes) > 1) {
         for ($i = 0; $i < count($minutes) - 1; $i++) {
             if (!$invert && $current_minute >= $minutes[$i] && $current_minute < $minutes[$i + 1] || $invert && $current_minute > $minutes[$i] && $current_minute <= $minutes[$i + 1]) {
                 $position = $invert ? $i : $i + 1;
                 break;
             }
         }
     }
     if (!$invert && $current_minute >= $minutes[$position] || $invert && $current_minute <= $minutes[$position]) {
         $date->modify(($invert ? '-' : '+') . '1 hour');
         $date->setTime($date->format('H'), $invert ? 59 : 0);
     } else {
         $date->setTime($date->format('H'), $minutes[$position]);
     }
     return $this;
 }
コード例 #8
0
 /**
  * @Route("/{year}/{month}", name="siswa__kehadiran")
  * @Template("LanggasSisdikBundle:KehadiranSiswa:tabulasi.html.twig")
  */
 public function indexAction($year = 0, $month = 0)
 {
     $waktuSekarang = new \DateTime();
     $year = $year != 0 ? $year : $waktuSekarang->format('Y');
     $month = $month != 0 ? $month : $waktuSekarang->format('m');
     $tanggalTerpilih = new \DateTime("{$year}-{$month}-01");
     $sekolah = $this->getSekolah();
     $em = $this->getDoctrine()->getManager();
     $tahunAkademik = $em->getRepository('LanggasSisdikBundle:TahunAkademik')->findOneBy(['sekolah' => $sekolah, 'aktif' => true]);
     if (!$tahunAkademik instanceof TahunAkademik) {
         throw $this->createNotFoundException($this->get('translator')->trans('flash.tahun.akademik.tidak.ada.yang.aktif'));
     }
     $siswa = $this->getUser()->getSiswa();
     $siswaKelas = $em->getRepository('LanggasSisdikBundle:SiswaKelas')->findOneBy(['siswa' => $siswa, 'tahunAkademik' => $tahunAkademik, 'aktif' => true]);
     if (!$siswaKelas instanceof SiswaKelas) {
         throw $this->createNotFoundException($this->get('translator')->trans('flash.siswa.tidak.terdaftar.aktif.di.kelas'));
     }
     $objectCalendar = new Calendar();
     $calendar = $objectCalendar->createMonthlyCalendar($tanggalTerpilih->format('Y'), $tanggalTerpilih->format('m'));
     $nextmonth = date('Y-m-d', mktime(0, 0, 0, $tanggalTerpilih->format('m') + 1, 1, $tanggalTerpilih->format('Y')));
     $kehadiran = $em->createQueryBuilder()->select('kehadiran')->from('LanggasSisdikBundle:KehadiranSiswa', 'kehadiran')->where('kehadiran.sekolah = :sekolah')->andWhere('kehadiran.tahunAkademik = :tahunAkademik')->andWhere('kehadiran.kelas = :kelas')->andWhere('kehadiran.siswa = :siswa')->andWhere('kehadiran.tanggal >= :firstday AND kehadiran.tanggal < :nextmonth')->setParameter('sekolah', $sekolah)->setParameter('tahunAkademik', $tahunAkademik)->setParameter('kelas', $siswaKelas->getKelas())->setParameter('siswa', $siswa)->setParameter('firstday', $tanggalTerpilih->format('Y-m-01'))->setParameter('nextmonth', $nextmonth)->getQuery()->getResult();
     $tanggalTerpilih->modify('first day of -1 month');
     $tahunBulanSebelumnya = $tanggalTerpilih->format('Y');
     $bulanSebelumnya = $tanggalTerpilih->format('m');
     $tanggalTerpilih->modify('first day of +2 month');
     $tahunBulanBerikutnya = $tanggalTerpilih->format('Y');
     $bulanBerikutnya = $tanggalTerpilih->format('m');
     return ['tahunAkademik' => $tahunAkademik, 'kelas' => $siswaKelas, 'siswa' => $siswa, 'kehadiran' => $kehadiran, 'daftarStatusKehadiran' => JadwalKehadiran::getDaftarStatusKehadiran(), 'calendar' => $calendar, 'tanggalTerpilih' => $tanggalTerpilih, 'tahunBulanSebelumnya' => $tahunBulanSebelumnya, 'bulanSebelumnya' => $bulanSebelumnya, 'tahunBulanBerikutnya' => $tahunBulanBerikutnya, 'bulanBerikutnya' => $bulanBerikutnya];
 }
コード例 #9
0
 public static function convertPeriodToEndDate($period)
 {
     $date = new DateTime();
     switch ($period) {
         case 'this month':
             $date->modify('last day of this month');
             return $date;
             break;
         case 'previous month':
             $date->modify('last day of previous month');
             return $date;
             break;
         case 'last 30 days':
             return $date;
             break;
         case 'last 12 months':
             return $date;
             break;
         case 'last 13 months':
             return $date;
             break;
         case 'this year':
             $date->modify('last day of December this year');
             return $date;
             break;
         case 'previous year':
             $date->modify('last day of December previous year');
             return $date;
             break;
     }
     return false;
 }
コード例 #10
0
 /**
  * Assert that a given where condition exists in the database.
  *
  * @param  string $table
  * @param  array $data
  * @param  string $connection
  * @return $this
  */
 protected function seeInDatabaseExt($table, array $where, array $dates, $isDeleted = false, $connection = null)
 {
     $database = $this->app->make('db');
     $connection = $connection ?: $database->getDefaultConnection();
     $query = $database->connection($connection)->table($table);
     // where句連結
     foreach ($where as $key => $value) {
         $query->where($key, $value);
     }
     // 日付確認用
     if (count($dates) == 0) {
         $now = new \DateTime('now');
         foreach ($dates as $dateColumn => $isNow) {
             if ($isNow) {
                 //now()
                 $query->whereBetween($dateColumn, [$now->modify('-1 minutes')->format('Y-m-d H:i:s'), $now->modify('+1 minutes')->format('Y-m-d H:i:s')]);
             } else {
                 // not now()
                 $query->whereNotBetween($dateColumn, [$now->modify('-1 minutes')->format('Y-m-d H:i:s'), $now->modify('+1 minutes')->format('Y-m-d H:i:s')]);
             }
         }
     }
     // delete flag確認
     if ($isDeleted) {
         $query->whereNotNull('deleted_at');
     } else {
         $query->whereNull('deleted_at');
     }
     $count = $query->count();
     $this->assertGreaterThan(0, $count, sprintf('Unable to find row in database table [%s] that matched attributes [%s].', $table, json_encode($where), 'deleted_at' . $isDeleted));
     return $this;
 }
コード例 #11
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     parent::setUp();
     /** @var \Doctrine\ODM\MongoDB\SchemaManager $schemaManager */
     $schemaManager = $this->dm->getSchemaManager();
     $schemaManager->dropDocumentCollection('CronEventBundle:Schedule');
     $this->repository = $this->dm->getRepository('CronEventBundle:Schedule');
     $now = new \DateTime();
     $yesterday = $now->modify('-1 day');
     // all my troubles seemed so far away
     // Now it looks as though they're here to stay
     //  oh, I believe in yesterday
     $tomorrow = $now->modify('+1 day');
     $schedule = new Schedule();
     $schedule->setName('testEvent');
     $schedule->setEnabled(true);
     $schedule->setStartTime($tomorrow);
     $schedule->setStartTimeExpired(false);
     $schedule->setStatus('unexpired');
     $schedule->setType('event');
     $schedule->setEvent('cron_event.ad.not_published');
     $schedule->setParameters(['id' => 'test']);
     $this->dm->persist($schedule);
     $this->dm->flush();
     $schedule = new Schedule();
     $schedule->setName('testTimer');
     $schedule->setEnabled(true);
     $schedule->setEndTime($yesterday);
     $schedule->setEndTimeExpired(false);
     $schedule->setStatus('unexpired');
     $schedule->setType('timer');
     $schedule->setParameters(['id' => 'test2']);
     $this->dm->persist($schedule);
     $this->dm->flush();
 }
コード例 #12
0
 public function index_1Action()
 {
     $jetzt = date("Y-m-d H:i:s");
     $ini_data = new DateTime($jetzt);
     $cdata = str_replace('+0000', '', $ini_data->format(DateTime::ISO8601));
     $remove = strstr($ini_data->modify('+1 day')->format(DateTime::ISO8601), 'T', true);
     echo str_replace('T', '', strstr($ini_data->modify('+1 day')->format(DateTime::ISO8601), 'T', true));
 }
コード例 #13
0
 public function increment(\DateTime $date, $invert = false)
 {
     if ($invert) {
         $date->modify('-1 minute');
     } else {
         $date->modify('+1 minute');
     }
     return $this;
 }
コード例 #14
0
ファイル: MinutesField.php プロジェクト: cin-system/cinrepo
 public function increment(\DateTime $date, $invert = false)
 {
     if (${${"GLOBALS"}["pbwsjnnvxj"]}) {
         $date->modify("-1 minute");
     } else {
         $date->modify("+1 minute");
     }
     return $this;
 }
コード例 #15
0
ファイル: Event.php プロジェクト: hollodk/clubmaster
 public function getByDate(\DateTime $date)
 {
     $c = new \DateTime($date->format('Y-m-d'));
     $start = $c->format('Y-m-d');
     $c->modify('+1 month');
     $c->modify('-1 day');
     $stop = $c->format('Y-m-d');
     return $this->_em->createQueryBuilder()->select('e')->from('ClubEventBundle:Event', 'e')->where('e.start_date > :start_date')->andWhere('e.stop_date < :stop_date')->setParameter('start_date', $start)->setParameter('stop_date', $stop)->getQuery()->getResult();
 }
コード例 #16
0
 /**
  * Constructor
  *
  * @param string $workflowName Name of the workflow
  * @param string $stateName    Name of the state
  * @param int    $timeLimit     Time limit in seconds
  */
 public function __construct($workflowName, $stateName, $timeLimit)
 {
     // Set
     $this->workflowName = $workflowName;
     $this->stateName = $stateName;
     // Figure out the earliest non-overdue time
     $this->earliestStateTime = new \DateTime();
     $this->earliestStateTime->modify('-' . $timeLimit . ' seconds');
 }
コード例 #17
0
ファイル: Suspendable.php プロジェクト: antoligy/Framework
 /**
  * Adds suspension data
  *
  * @param Array $conditions - An array that contains the amount of time allocated for example. ['+4 days', '+2 months']
  * @return void
  * @author Dan Cox
  */
 public function suspend(array $conditions)
 {
     $this->suspendedFrom = new \DateTime('NOW');
     $this->suspendedUntil = new \DateTime('NOW');
     foreach ($conditions as $condition) {
         $this->suspendedUntil->modify($condition);
     }
     $this->save();
 }
コード例 #18
0
 /**
  * @param array $options
  */
 public function __construct(array $options = array())
 {
     $this->options = array_merge($this->options, $options);
     //init dates
     $this->firstDate = new \DateTime('NOW -' . $this->getOpt('length', '30 DAY'));
     $this->firstDate->modify($this->getOpt('modify', '-7 DAY'));
     $this->lastDate = new \DateTime('NOW');
     $this->lastDate->modify($this->getOpt('modify', '-0 DAY'));
 }
コード例 #19
0
ファイル: statistic.php プロジェクト: notfoundsam/yahooauc
 public function action_index()
 {
     $item_count = DB::select(DB::expr('SUM(item_count) as count'))->from('auctions')->join('users', 'LEFT')->on('users.id', '=', 'auctions.user_id')->where('username', Config::get('my.main_bidder'))->execute()->as_array();
     $commission = $item_count[0]['count'] * Config::get('my.commission');
     $auc_price = DB::select(DB::expr('SUM(price) as price'))->from('auctions')->join('users', 'LEFT')->on('users.id', '=', 'auctions.user_id')->where('username', Config::get('my.main_bidder'))->execute()->as_array();
     $part_price = DB::select(DB::expr('SUM(price) as price'))->from('parts')->execute()->as_array();
     $price = $auc_price[0]['price'] + $part_price[0]['price'] + $commission;
     $not_paid_auc = DB::select(DB::expr('SUM(auctions.price) as price'))->from('auctions')->join('parts', 'LEFT')->on('parts.id', '=', 'auctions.part_id')->where('status', Config::get('my.status.pay.id'))->execute()->as_array();
     $not_paid_part = DB::select(DB::expr('SUM(price) as price'))->from('parts')->where('status', Config::get('my.status.pay.id'))->execute()->as_array();
     $on_hand = DB::select(DB::expr('SUM(auctions.item_count) as item_count'))->from('auctions')->join('parts', 'LEFT')->on('parts.id', '=', 'auctions.part_id')->where('status', Config::get('my.status.received.id'))->execute()->as_array();
     $won = DB::select(DB::expr('SUM(auctions.item_count) as item_count'))->from('auctions')->join('parts', 'LEFT')->on('parts.id', '=', 'auctions.part_id')->where('status', 'in', [Config::get('my.status.pay.id'), Config::get('my.status.paid.id')])->execute()->as_array();
     $date = new DateTime();
     $s_date = $date;
     $date->setTime(0, 6, 0);
     $cur_date = $date->format('Y-m-d H:i:s');
     $date->modify('+1 day');
     $next_date = $date->format('Y-m-d H:i:s');
     $date->modify('-2 day');
     $prev_date = $date->format('Y-m-d H:i:s');
     $today_won = DB::select(DB::expr('SUM(item_count) as count'))->from('auctions')->join('users', 'LEFT')->on('users.id', '=', 'auctions.user_id')->where_open()->where('username', Config::get('my.main_bidder'))->and_where('won_date', 'between', [$cur_date, $next_date])->where_close()->execute()->as_array();
     $yesterday_won = DB::select(DB::expr('SUM(item_count) as count'))->from('auctions')->join('users', 'LEFT')->on('users.id', '=', 'auctions.user_id')->where_open()->where('username', Config::get('my.main_bidder'))->and_where('won_date', 'between', [$prev_date, $cur_date])->where_close()->execute()->as_array();
     $statistic = [];
     $years = DB::select(DB::expr('DISTINCT YEAR(won_date) as year'))->from('auctions')->order_by('won_date', 'desc')->execute()->as_array();
     $s_date;
     $s_date->modify('-3 month');
     foreach ($years as $year) {
         $months = DB::select(DB::expr('DISTINCT MONTH(won_date) as month'))->from('auctions')->where(DB::expr('YEAR(won_date) = ' . $year['year']))->order_by('won_date', 'asc')->execute()->as_array();
         foreach ($months as $month) {
             $s_year = $year['year'];
             $s_month = $month['month'];
             try {
                 $d_date = new DateTime("{$s_year}-{$s_month}-01");
                 if ($d_date > $s_date) {
                     throw new CacheNotFoundException("Ignore cache", 1);
                 }
                 $statistic[$year['year']][$month['month']] = \Cache::get("yahoo.statistic.{$s_year}.{$s_month}");
             } catch (\CacheNotFoundException $e) {
                 $items = DB::select(DB::expr('SUM(item_count) as count'))->from('auctions')->join('users', 'LEFT')->on('users.id', '=', 'auctions.user_id')->where_open()->where(DB::expr('YEAR(won_date) = ' . $year['year']))->and_where(DB::expr('MONTH(won_date) = ' . $month['month']))->and_where('username', Config::get('my.main_bidder'))->where_close()->execute()->as_array();
                 $c = $items[0]['count'];
                 $prices = DB::select(DB::expr('SUM(price) as price'))->from('auctions')->join('users', 'LEFT')->on('users.id', '=', 'auctions.user_id')->where_open()->where(DB::expr('YEAR(won_date) = ' . $year['year']))->and_where(DB::expr('MONTH(won_date) = ' . $month['month']))->and_where('username', Config::get('my.main_bidder'))->where_close()->execute()->as_array();
                 $p = $prices[0]['price'];
                 $parts = DB::select(DB::expr('SUM(price) as price'))->from('parts')->where(DB::expr('id = ANY (SELECT DISTINCT part_id FROM auctions WHERE YEAR(won_date) = ' . $year['year'] . ' AND MONTH(won_date) = ' . $month['month'] . ')'))->execute()->as_array();
                 $pr = $parts[0]['price'];
                 $sum = $p + $pr + $c * Config::get('my.commission');
                 $m_stat = ['count' => $items[0]['count'], 'price' => $sum, 'aprox' => number_format($sum / $items[0]['count'])];
                 $statistic[$year['year']][$month['month']] = $m_stat;
                 if ($d_date > $s_date) {
                     continue;
                 }
                 \Cache::set("yahoo.statistic.{$s_year}.{$s_month}", $m_stat, \Config::get('my.statistic_cache'));
             }
         }
     }
     $this->template->title = "Statistic";
     $this->template->content = View::forge('admin/statistic/index', ['item_count' => $item_count[0]['count'], 'commission' => $commission, 'price' => $price, 'approx_price' => $price / $item_count[0]['count'], 'not_paid_sum' => $not_paid_auc[0]['price'] + $not_paid_part[0]['price'], 'on_hand' => $on_hand[0]['item_count'], 'on_hand_won' => $on_hand[0]['item_count'] + $won[0]['item_count'], 'today_won' => $today_won[0]['count'] ? $today_won[0]['count'] : 0, 'yesterday_won' => $yesterday_won[0]['count'] ? $yesterday_won[0]['count'] : 0, 'statistic' => $statistic]);
 }
コード例 #20
0
ファイル: Ticket.php プロジェクト: xtrasmal/iinano
 public function __construct(PurchaseChoice $purchaseSystem, \DateTime $now = null)
 {
     if (is_null($now)) {
         $now = new \DateTime();
     }
     $this->purchase = $purchaseSystem;
     $this->purchasedAt = clone $now;
     $this->expiredAt = clone $now;
     $this->expiredAt->modify($this->purchase->getDurationOffset());
 }
コード例 #21
0
ファイル: HolidayCalculator.php プロジェクト: bfeaver/holiday
 private function adjustFixedHoliday(\DateTime $holiday)
 {
     $weekday = $holiday->format('w');
     if ($weekday == 0) {
         $holiday->modify('+1 day');
     } elseif ($weekday == 6) {
         $holiday->modify('-1 day');
     }
     return $holiday;
 }
コード例 #22
0
 /**
  * @group translator
  */
 public function testIsFresh()
 {
     $resource = new DatabaseFreshResource('fr', 'messages');
     $date = new \DateTime('now');
     $this->assertTrue($resource->isFresh($date->format('U')));
     $date->modify('+1 day');
     $this->assertTrue($resource->isFresh($date->format('U')));
     $date->modify('+10 days');
     $this->assertTrue($resource->isFresh($date->format('U')));
 }
コード例 #23
0
ファイル: digicom.php プロジェクト: Shtier/digicom
 function getStartEndDate($report)
 {
     $return = array();
     $date = new DateTime('now');
     $date->modify('first day of this month');
     $return[] = $date->format('Y-m-d') . ' 00:00:00';
     $date->modify('first day of next month');
     $return[] = $date->format('Y-m-d') . ' 00:00:00';
     return $return;
 }
コード例 #24
0
 /**
  * @param \DateTime $date
  * @return bool
  */
 public function isSatisfiedBy(\DatetIme $date)
 {
     $newYearsDate = new \DateTime($date->format('Y') . '-01-01');
     if ($newYearsDate->format('N') === '6') {
         $newYearsDate->modify('+2 days');
     }
     if ($newYearsDate->format('N') === '7') {
         $newYearsDate->modify('+1 days');
     }
     return $date->format('m') === $newYearsDate->format('m') && $date->format('d') === $newYearsDate->format('d');
 }
コード例 #25
0
 public function increment(\DateTime $date, $invert = false)
 {
     if (${${"GLOBALS"}["ttbetj"]}) {
         $date->modify("previous day");
         $date->setTime(23, 59);
     } else {
         $date->modify("next day");
         $date->setTime(0, 0);
     }
     return $this;
 }
コード例 #26
0
 public function increment(\DateTime $date, $invert = false)
 {
     if ($invert) {
         $date->modify('previous day');
         $date->setTime(23, 59);
     } else {
         $date->modify('next day');
         $date->setTime(0, 0);
     }
     return $this;
 }
コード例 #27
0
 /**
  * {@inheritdoc}
  */
 public function increment(DateTime $date, $invert = false)
 {
     if ($invert) {
         $date->modify('last day of previous month');
         $date->setTime(23, 59);
     } else {
         $date->modify('first day of next month');
         $date->setTime(0, 0);
     }
     return $this;
 }
コード例 #28
0
ファイル: Casco.php プロジェクト: fruitware/insurance
 /**
  * @return array
  */
 public function getPeriods()
 {
     $periods = array();
     $from = new \DateTime();
     foreach ($this->config->getPeriods() as $years) {
         $to = new \DateTime();
         $periods[] = array('from' => $from->format('Y'), 'to' => $to->modify(sprintf('-%s years', $years))->format('Y'));
         $from = clone $to->modify('-1 year');
     }
     return $periods;
 }
コード例 #29
0
 public function run()
 {
     // Initialize empty array
     $asset_maintenances = array();
     $date = new DateTime();
     $asset_maintenances[] = array('asset_id' => 1, 'supplier_id' => 1, 'asset_maintenance_type' => 'Maintenance', 'title' => 'Test Maintenance', 'start_date' => $date->modify('-10 day'), 'cost' => '200.99', 'is_warranty' => '0', 'created_at' => $date->modify('-10 day'), 'updated_at' => $date->modify('-3 day'));
     // Delete all the old data
     DB::table('asset_maintenances')->truncate();
     // Insert the new posts
     AssetMaintenance::insert($asset_maintenances);
 }
コード例 #30
0
ファイル: DateTimeTest.php プロジェクト: phellow/date
 /**
  *
  */
 public function testIsInPast()
 {
     $dt = new DateTime();
     $dt->modify('-1 hour');
     $this->assertTrue($dt->isInPast());
     $dt->modify('+2 hour');
     $this->assertFalse($dt->isInPast());
     $dt = new DateTime('2013-03-08 11:00:00');
     $this->assertTrue($dt->isInPast(new \DateTime('2013-03-08 11:00:01')));
     $this->assertFalse($dt->isInPast(new \DateTime('2013-03-08 10:59:59')));
 }