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


PHP Date_Calc::isoWeekDate方法代码示例

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


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

示例1: gregorianToISO

 /**
  * Converts from Gregorian Year-Month-Day to ISO Year-WeekNumber-WeekDay
  *
  * Uses ISO 8601 definitions.
  *
  * @param int $day   the day of the month
  * @param int $month the month
  * @param int $year  the year.  Use the complete year instead of the
  *                    abbreviated version.  E.g. use 2005, not 05.
  *
  * @return   string     the date in ISO Year-WeekNumber-WeekDay format
  * @access   public
  * @static
  */
 function gregorianToISO($day, $month, $year)
 {
     list($yearnumber, $weeknumber, $weekday) = Date_Calc::isoWeekDate($day, $month, $year);
     return sprintf("%04d", $yearnumber) . '-' . sprintf("%02d", $weeknumber) . '-' . $weekday;
 }
开发者ID:222elm,项目名称:dotprojectFrame,代码行数:19,代码来源:Calc.php

示例2: array

// for( $i=0;$i<$cnt;$i++ ){
//     $parts      = explode(':',$wkno[$i]);
//     $weeksno[$parts[0]] = str_replace("\n",'',$parts[1]);
// }
// unset($wkno);
// foreach($weeksno as $date=>$iso){
//     $year       = substr($date,0,4);
//     $month      = substr($date,4,2);
//     $day        = substr($date,6);
//     $iso9601 = Date_Calc::gregorianToISO($day,$month,$year);
//     if($iso9601!=$iso){
//         $failed_test_data   = true;
//         echo $date . '(' . $iso . ') =>' . $year.'-'.$month.'-'.$day .'=>' . $iso9601 . " : failed\n";
//     }
// }
/**
 * Bugs #19788
 */
$failed_test_19788 = false;
$pass1 = array(1998, 2, 1) == Date_Calc::isoWeekDate(5, 1, 1998) ? true : false;
$pass2 = array(1998, 2, 2) == Date_Calc::isoWeekDate(6, 1, 1998) ? true : false;
$pass3 = array(2004, 2, 1) == Date_Calc::isoWeekDate(5, 1, 2004) ? true : false;
$pass4 = array(2004, 2, 2) == Date_Calc::isoWeekDate(6, 1, 2004) ? true : false;
if (!($pass1 && $pass2 && $pass3 && $pass4)) {
    $failed_test_19788 = true;
}
if ($failed_test_19788 || $failed_test_data) {
    echo "Bug #19788: failed\n";
} else {
    echo "Bug #19788: OK\n";
}
开发者ID:MagnusA,项目名称:Date,代码行数:31,代码来源:test_calc.php

示例3: format2


//.........这里部分代码省略.........
                     $hs_partsec = str_pad($hs_partsec, $hn_partsecdigits, "0", STR_PAD_RIGHT);
                 }
                 $ret .= $hs_partsec;
                 $i += $hn_codelen;
                 break;
             case "h":
             case "H":
                 if ($this->ob_invalidtime) {
                     return $this->_getErrorInvalidTime();
                 }
                 if (strtoupper(substr($ps_format, $i, 4)) == "HH12") {
                     $hn_hour = $this->hour % 12;
                     if ($hn_hour == 0) {
                         $hn_hour = 12;
                     }
                     $hn_codelen = 4;
                 } else {
                     // Code 'HH' or 'HH24':
                     //
                     $hn_hour = $this->hour;
                     $hn_codelen = strtoupper(substr($ps_format, $i, 4)) == "HH24" ? 4 : 2;
                 }
                 $hs_numberformat = substr($ps_format, $i + $hn_codelen, 4);
                 $hs_hour = $this->_formatNumber($hn_hour, $hs_numberformat, 2, $hb_nopad, true, $ps_locale);
                 if (Pear::isError($hs_hour)) {
                     return $hs_hour;
                 }
                 $ret .= $hs_hour;
                 $i += $hn_codelen + strlen($hs_numberformat);
                 break;
             case "i":
             case "I":
                 if (is_null($hn_isoyear)) {
                     list($hn_isoyear, $hn_isoweek, $hn_isoday) = Date_Calc::isoWeekDate($this->day, $this->month, $this->year);
                 }
                 if (strtoupper(substr($ps_format, $i, 2)) == "ID" && strtoupper(substr($ps_format, $i + 1, 3)) != "DAY") {
                     $hs_numberformat = substr($ps_format, $i + 2, 4);
                     $hs_isoday = $this->_formatNumber($hn_isoday, $hs_numberformat, 1, $hb_nopad, true, $ps_locale);
                     if (Pear::isError($hs_isoday)) {
                         return $hs_isoday;
                     }
                     $ret .= $hs_isoday;
                     $i += 2 + strlen($hs_numberformat);
                 } else {
                     if (strtoupper(substr($ps_format, $i, 2)) == "IW") {
                         $hs_numberformat = substr($ps_format, $i + 2, 4);
                         $hs_isoweek = $this->_formatNumber($hn_isoweek, $hs_numberformat, 2, $hb_nopad, true, $ps_locale);
                         if (Pear::isError($hs_isoweek)) {
                             return $hs_isoweek;
                         }
                         $ret .= $hs_isoweek;
                         $i += 2 + strlen($hs_numberformat);
                     } else {
                         // Code I(YYY...):
                         //
                         $hn_codelen = 1;
                         while (strtoupper(substr($ps_format, $i + $hn_codelen, 1)) == "Y") {
                             ++$hn_codelen;
                         }
                         $hs_numberformat = substr($ps_format, $i + $hn_codelen, 4);
                         $hs_isoyear = $this->_formatNumber($hn_isoyear, $hs_numberformat, $hn_codelen, $hb_nopad, $hb_nosign, $ps_locale);
                         if (Pear::isError($hs_isoyear)) {
                             return $hs_isoyear;
                         }
                         $ret .= $hs_isoyear;
                         $i += $hn_codelen + strlen($hs_numberformat);
开发者ID:,项目名称:,代码行数:67,代码来源:

示例4: isoWeekToDate

 /**
  * Converts the Week number and Day-of-Week to Date
  *
  * Calculation algorithm taken from
  * {@link http://www.merlyn.demon.co.uk/weekcalc.htm}.
  *
  * @param int    $dow    day of week from 1 (Monday) to 7 (Sunday)
  * @param int    $week   number of week from 1 to 53
  * @param int    $year   four digits of year
  * @param string $format the output format
  *
  * @return  string formatted date
  * @access  public
  * @static
  * @since   Method available since Release 1.5.0a2
  */
 function isoWeekToDate($dow, $week, $year, $format = DATE_CALC_FORMAT)
 {
     // validates the week number
     list(, $nweeks) = Date_Calc::isoWeekDate(28, 12, $year);
     if ($week > $nweeks) {
         return PEAR::raiseError("ISO week number for {$year} cannot be greater than {$nweeks}", DATE_ERROR_INVALIDDATE);
     }
     // validates the day of week
     if ($dow < 1 || $dow > 7) {
         return PEAR::raiseError("ISO day of week must be between 1 and 7", DATE_ERROR_INVALIDDATE);
     }
     // finds the day of week of January 4th.
     $jan4th = Date_Calc::dayOfWeek(4, 1, $year);
     if ($jan4th == 0) {
         $jan4th = 7;
     }
     // offset to the monday of that week
     $offset = -($jan4th - 1);
     // increment the days starting from january 4th.
     $days = Date_Calc::dateToDays(1, 1, $year) + $offset + 7 * ($week - 1) + ($dow - 1) + 3;
     return Date_Calc::daysToDate($days, $format);
 }
开发者ID:milk54,项目名称:geeklog-japan,代码行数:38,代码来源:Calc.php


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