コード例 #1
0
ファイル: DateUnit.php プロジェクト: dgame/php-time
 /**
  * Date constructor.
  *
  * @param TimeUnit $unit
  */
 public function __construct(TimeUnit $unit)
 {
     $days = $unit->inDays();
     //        var_dump($days);
     $year = floor($days->getAmount() / Days::YEAR);
     $days = new Days($days->getAmount() - $year * Days::YEAR);
     //        var_dump($year);
     //        var_dump($days);
     $month = floor($days->getAmount() / Days::MONTH);
     $days = new Days($days->getAmount() - $month * Days::MONTH);
     //        var_dump($month);
     //        var_dump($days);
     $week = floor($days->getAmount() / Days::WEEK);
     $days = new Days($days->getAmount() - $week * Days::WEEK);
     //        var_dump($week);
     //        var_dump($days);
     $day = floor($days->getAmount());
     $days = new Days($days->getAmount() - $day);
     //        var_dump($day);
     //        var_dump($days);
     $hour = floor($days->getAmount() * Days::HOURS);
     $days = new Days($days->getAmount() - $hour / Days::HOURS);
     //        var_dump($hour);
     //        var_dump($days);
     $minute = floor($days->getAmount() * Days::MINUTES);
     $days = new Days($days->getAmount() - $minute / Days::MINUTES);
     //        var_dump($min);
     //        var_dump($days);
     $second = ceil($days->getAmount() * Days::SECONDS);
     //        var_dump($seconds);
     $this->years = new Years($year);
     $this->months = new Months($month);
     $this->weeks = new Weeks($week);
     $this->days = new Days($day);
     $this->hours = new Hours($hour);
     $this->minutes = new Minutes($minute);
     $this->seconds = new Seconds($second);
 }
コード例 #2
0
ファイル: HttpClient.php プロジェクト: dgame/php-http-client
 /**
  * @param TimeUnit $unit
  *
  * @return HttpClient
  */
 public function setConnectionTimeout(TimeUnit $unit) : HttpClient
 {
     return $this->setOption(CURLOPT_CONNECTTIMEOUT, $unit->inSeconds()->getAmount());
 }