当前位置: 首页>>代码示例>>PHP>>正文


PHP Date_Calc::secondsPastMidnight方法代码示例

本文整理汇总了PHP中Date_Calc::secondsPastMidnight方法的典型用法代码示例。如果您正苦于以下问题:PHP Date_Calc::secondsPastMidnight方法的具体用法?PHP Date_Calc::secondsPastMidnight怎么用?PHP Date_Calc::secondsPastMidnight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Date_Calc的用法示例。


在下文中一共展示了Date_Calc::secondsPastMidnight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: round

 /**
  * Rounds the date according to the specified precision
  *
  * The precision parameter must be one of the following constants:
  *
  *  <code>DATE_PRECISION_YEAR</code>
  *  <code>DATE_PRECISION_MONTH</code>
  *  <code>DATE_PRECISION_DAY</code>
  *  <code>DATE_PRECISION_HOUR</code>
  *  <code>DATE_PRECISION_10MINUTES</code>
  *  <code>DATE_PRECISION_MINUTE</code>
  *  <code>DATE_PRECISION_10SECONDS</code>
  *  <code>DATE_PRECISION_SECOND</code>
  *
  * The precision can also be specified as an integral offset from
  * one of these constants, where the offset reflects a precision
  * of 10 to the power of the offset greater than the constant.
  * For example:
  *
  *  <code>DATE_PRECISION_YEAR - 1</code> rounds the date to the nearest 10
  *                                      years
  *  <code>DATE_PRECISION_YEAR - 3</code> rounds the date to the nearest 1000
  *                                      years
  *  <code>DATE_PRECISION_SECOND + 1</code> rounds the date to 1 decimal
  *                                        point of a second
  *  <code>DATE_PRECISION_SECOND + 1</code> rounds the date to 3 decimal
  *                                        points of a second
  *  <code>DATE_PRECISION_SECOND + 1</code> rounds the date to the nearest 10
  *                                        seconds (thus it is equivalent to
  *                                        DATE_PRECISION_10SECONDS)
  *
  * N.B. This function requires a time in UTC if both the precision is at
  * least DATE_PRECISION_SECOND and leap seconds are being counted, otherwise
  * any local time is acceptable.
  *
  * @param int   $pn_precision a 'DATE_PRECISION_*' constant
  * @param int   $pn_day       the day of the month
  * @param int   $pn_month     the month
  * @param int   $pn_year      the year
  * @param int   $pn_hour      the hour
  * @param int   $pn_minute    the minute
  * @param mixed $pn_second    the second as integer or float
  * @param bool  $pb_countleap whether to count leap seconds (defaults to
  *                             DATE_COUNT_LEAP_SECONDS)
  *
  * @return   array      array of year, month, day, hour, minute, second
  * @access   public
  * @static
  * @since    Method available since Release 1.5.0
  */
 function round($pn_precision, $pn_day, $pn_month, $pn_year, $pn_hour = 0, $pn_minute = 0, $pn_second = 0, $pb_countleap = DATE_COUNT_LEAP_SECONDS)
 {
     if ($pn_precision <= DATE_PRECISION_YEAR) {
         $hn_month = 0;
         $hn_day = 0;
         $hn_hour = 0;
         $hn_minute = 0;
         $hn_second = 0;
         if ($pn_precision < DATE_PRECISION_YEAR) {
             $hn_year = round($pn_year, $pn_precision - DATE_PRECISION_YEAR);
         } else {
             // Check part-year:
             //
             $hn_midyear = (Date_Calc::firstDayOfYear($pn_year + 1) - Date_Calc::firstDayOfYear($pn_year)) / 2;
             if (($hn_days = Date_Calc::dayOfYear($pn_day, $pn_month, $pn_year)) <= $hn_midyear - 1) {
                 $hn_year = $pn_year;
             } else {
                 if ($hn_days >= $hn_midyear) {
                     // Round up:
                     //
                     $hn_year = $pn_year + 1;
                 } else {
                     // Take time into account:
                     //
                     $hn_partday = Date_Calc::secondsPastMidnight($pn_hour, $pn_minute, $pn_second) / 86400;
                     if ($hn_partday >= $hn_midyear - $hn_days) {
                         // Round up:
                         //
                         $hn_year = $pn_year + 1;
                     } else {
                         $hn_year = $pn_year;
                     }
                 }
             }
         }
     } else {
         if ($pn_precision == DATE_PRECISION_MONTH) {
             $hn_year = $pn_year;
             $hn_day = 0;
             $hn_hour = 0;
             $hn_minute = 0;
             $hn_second = 0;
             $hn_firstofmonth = Date_Calc::firstDayOfMonth($pn_month, $pn_year);
             $hn_midmonth = (Date_Calc::lastDayOfMonth($pn_month, $pn_year) + 1 - $hn_firstofmonth) / 2;
             if (($hn_days = Date_Calc::dateToDays($pn_day, $pn_month, $pn_year) - $hn_firstofmonth) <= $hn_midmonth - 1) {
                 $hn_month = $pn_month;
             } else {
                 if ($hn_days >= $hn_midmonth) {
                     // Round up:
                     //
//.........这里部分代码省略.........
开发者ID:222elm,项目名称:dotprojectFrame,代码行数:101,代码来源:Calc.php

示例2: setStandardTime

 /**
  * Sets local standard time and then calculates local time (i.e.
  * Summer-time-adjusted)
  *
  * @param int   $pn_day        the day
  * @param int   $pn_month      the month
  * @param int   $pn_year       the year
  * @param int   $pn_hour       the hour
  * @param int   $pn_minute     the minute
  * @param int   $pn_second     the second
  * @param float $pn_partsecond the part-second
  *
  * @return   void
  * @access   protected
  * @see      Date::setLocalTime()
  * @since    Method available since Release 1.5.0
  */
 function setStandardTime($pn_day, $pn_month, $pn_year, $pn_hour, $pn_minute, $pn_second, $pn_partsecond)
 {
     settype($pn_day, "int");
     settype($pn_month, "int");
     settype($pn_year, "int");
     settype($pn_hour, "int");
     settype($pn_minute, "int");
     settype($pn_second, "int");
     settype($pn_partsecond, "float");
     $this->on_standardday = $pn_day;
     $this->on_standardmonth = $pn_month;
     $this->on_standardyear = $pn_year;
     $this->on_standardhour = $pn_hour;
     $this->on_standardminute = $pn_minute;
     $this->on_standardsecond = $pn_second;
     $this->on_standardpartsecond = $pn_partsecond;
     $this->ob_invalidtime = !$this->_secondsInDayIsValid();
     if ($this->tz->inDaylightTimeStandard(array($pn_day, $pn_month, $pn_year, Date_Calc::secondsPastMidnight($pn_hour, $pn_minute, $pn_second) + $pn_partsecond))) {
         // Calculate local time:
         //
         list($this->year, $this->month, $this->day, $this->hour, $this->minute, $this->second, $this->partsecond) = $this->_addOffset($this->tz->getDSTSavings(), $pn_day, $pn_month, $pn_year, $pn_hour, $pn_minute, $pn_second, $pn_partsecond);
     } else {
         // Time is already local time:
         //
         $this->day = $pn_day;
         $this->month = $pn_month;
         $this->year = $pn_year;
         $this->hour = $pn_hour;
         $this->minute = $pn_minute;
         $this->second = $pn_second;
         $this->partsecond = $pn_partsecond;
     }
 }
开发者ID:,项目名称:,代码行数:50,代码来源:


注:本文中的Date_Calc::secondsPastMidnight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。