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


PHP Date_Calc::weekOfYear4th方法代码示例

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


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

示例1: format2


//.........这里部分代码省略.........
                 //
                 $hs_unixtime = $this->_formatNumber($hn_unixtime, $hs_numberformat, 0, true, false, $ps_locale);
                 if (Pear::isError($hs_unixtime)) {
                     return $hs_unixtime;
                 }
                 $ret .= $hs_unixtime;
                 $i += 1 + strlen($hs_numberformat);
                 break;
             case "w":
             case "W":
                 // Check for 'WW' before 'W':
                 //
                 if (strtoupper(substr($ps_format, $i, 2)) == "WW") {
                     $hn_week = Date_Calc::weekOfYearAbsolute($this->day, $this->month, $this->year);
                     $hs_numberformat = substr($ps_format, $i + 2, 4);
                     $hs_week = $this->_formatNumber($hn_week, $hs_numberformat, 2, $hb_nopad, true, $ps_locale);
                     if (Pear::isError($hs_week)) {
                         return $hs_week;
                     }
                     $ret .= $hs_week;
                     $i += 2 + strlen($hs_numberformat);
                 } else {
                     if (strtoupper(substr($ps_format, $i, 2)) == "W1") {
                         $hn_week = Date_Calc::weekOfYear1st($this->day, $this->month, $this->year);
                         $hs_numberformat = substr($ps_format, $i + 2, 4);
                         $hs_week = $this->_formatNumber($hn_week, $hs_numberformat, 2, $hb_nopad, true, $ps_locale);
                         if (Pear::isError($hs_week)) {
                             return $hs_week;
                         }
                         $ret .= $hs_week;
                         $i += 2 + strlen($hs_numberformat);
                     } else {
                         if (strtoupper(substr($ps_format, $i, 2)) == "W4") {
                             $ha_week = Date_Calc::weekOfYear4th($this->day, $this->month, $this->year);
                             $hn_week = $ha_week[1];
                             $hs_numberformat = substr($ps_format, $i + 2, 4);
                             $hs_week = $this->_formatNumber($hn_week, $hs_numberformat, 2, $hb_nopad, true, $ps_locale);
                             if (Pear::isError($hs_week)) {
                                 return $hs_week;
                             }
                             $ret .= $hs_week;
                             $i += 2 + strlen($hs_numberformat);
                         } else {
                             if (strtoupper(substr($ps_format, $i, 2)) == "W7") {
                                 $ha_week = Date_Calc::weekOfYear7th($this->day, $this->month, $this->year);
                                 $hn_week = $ha_week[1];
                                 $hs_numberformat = substr($ps_format, $i + 2, 4);
                                 $hs_week = $this->_formatNumber($hn_week, $hs_numberformat, 2, $hb_nopad, true, $ps_locale);
                                 if (Pear::isError($hs_week)) {
                                     return $hs_week;
                                 }
                                 $ret .= $hs_week;
                                 $i += 2 + strlen($hs_numberformat);
                             } else {
                                 // Code 'W':
                                 //
                                 $hn_week = Date_Calc::weekOfMonthAbsolute($this->day, $this->month, $this->year);
                                 $hs_numberformat = substr($ps_format, $i + 1, 4);
                                 $hs_week = $this->_formatNumber($hn_week, $hs_numberformat, 1, $hb_nopad, true, $ps_locale);
                                 if (Pear::isError($hs_week)) {
                                     return $hs_week;
                                 }
                                 $ret .= $hs_week;
                                 $i += 1 + strlen($hs_numberformat);
                             }
                         }
开发者ID:,项目名称:,代码行数:67,代码来源:

示例2: weekOfYear4th

 /**
  * Returns week of the year counting week 1 as the week that contains 4th
  * January
  *
  * Week 1 is determined to be the week that includes the 4th January, and
  * therefore can be defined as the first week of the year that has at least
  * 4 days.  The previous week is counted as week 52 or 53 of the previous
  * year.  Note that this definition depends on which day is the first day of
  * the week, and that if this is not passed as the '$pn_firstdayofweek'
  * parameter, the default is assumed.
  *
  * Note also that the last day week of the year is likely to extend into
  * the following year, except in the case that the last day of the week
  * falls on 31st December.
  *
  * Also note that this is very similar to the ISO week returned by
  * 'isoWeekDate()', the difference being that the ISO week always has
  * 7 days, and if the 4th of January is a Friday, for example,
  * ISO week 1 would start on Monday, 31st December in the previous year,
  * whereas the week defined by this function would start on 1st January,
  * but would be only 6 days long.  Of course you can also set the day
  * of the week, whereas the ISO week starts on a Monday by definition.
  *
  * Returned week is an integer from 1 to 53.
  *
  * @param int $pn_day            the day of the month, default is current
  *                                local day
  * @param int $pn_month          the month, default is current local month
  * @param int $pn_year           the year in four digit format, default is
  *                                current local year
  * @param int $pn_firstdayofweek optional integer specifying the first day
  *                                of the week
  *
  * @return   array      array of year, week no as integers
  * @access   public
  * @static
  * @since    Method available since Release 1.5.0
  */
 function weekOfYear4th($pn_day = 0, $pn_month = 0, $pn_year = null, $pn_firstdayofweek = DATE_CALC_BEGIN_WEEKDAY)
 {
     if (is_null($pn_year)) {
         $pn_year = Date_Calc::dateNow('%Y');
     }
     if (empty($pn_month)) {
         $pn_month = Date_Calc::dateNow('%m');
     }
     if (empty($pn_day)) {
         $pn_day = Date_Calc::dateNow('%d');
     }
     $hn_wd1 = Date_Calc::daysToDayOfWeek(Date_Calc::firstDayOfYear($pn_year));
     $hn_day = Date_Calc::dayOfYear($pn_day, $pn_month, $pn_year);
     $hn_week = floor(($hn_day + (10 + $hn_wd1 - $pn_firstdayofweek) % 7 + 3) / 7);
     if ($hn_week > 0) {
         $hn_year = $pn_year;
     } else {
         // Week number is the last week of the previous year:
         //
         list($hn_year, $hn_lastmonth, $hn_lastday) = explode(" ", Date_Calc::daysToDate(Date_Calc::lastDayOfYear($pn_year - 1), "%Y %m %d"));
         list($hn_year, $hn_week) = Date_Calc::weekOfYear4th($hn_lastday, $hn_lastmonth, $hn_year, $pn_firstdayofweek);
     }
     return array((int) $hn_year, (int) $hn_week);
 }
开发者ID:222elm,项目名称:dotprojectFrame,代码行数:62,代码来源:Calc.php

示例3: getWeekNInYear

 /**
  * Returns the number of the week in the year (ISO-8601), given a date
  *
  * @param int $y year (2003)
  * @param int $m month (9)
  * @param int $d day (4)
  *
  * @return int week number
  * @access protected
  */
 function getWeekNInYear($y, $m, $d)
 {
     //return Date_Calc::weekOfYear($d, $m, $y); //beware, Date_Calc doesn't follow ISO-8601 standard!
     list($nYear, $nWeek) = Date_Calc::weekOfYear4th($d, $m, $y);
     return $nWeek;
 }
开发者ID:Esleelkartea,项目名称:kz-adeada-talleres-electricos-,代码行数:16,代码来源:PearDate.php


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