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


PHP Date_Calc::weekOfYear方法代码示例

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


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

示例1: _hours

 protected function _hours()
 {
     $hours_html = '';
     $dayWidth = round(100 / $this->_days);
     $week = Date_Calc::weekOfYear(1, $this->_start->month, $this->_start->year);
     $span = (7 - $week) % 7 + 1;
     $span_left = $this->_days;
     $t = new Horde_Date($this->_start);
     while ($span_left > 0) {
         $span_left -= $span;
         $week_label = Horde::url('#')->link(array('onclick' => 'return switchDateView(\'Week\',' . $t->dateString() . ');')) . "Week" . ' ' . $week . '</a>';
         $hours_html .= sprintf('<th colspan="%d" width="%s%%">%s</th>', $span, $dayWidth, $week_label);
         $week++;
         $t->mday += 7;
         $span = min($span_left, 7);
     }
     $hours_html .= '</tr><tr><td width="100" class="label">&nbsp;</td>';
     for ($i = 0; $i < $this->_days; $i++) {
         $t = new Horde_Date(array('month' => $this->_start->month, 'mday' => $this->_start->mday + $i, 'year' => $this->_start->year));
         $day_label = Horde::url('#')->link(array('onclick' => 'return switchDateView(\'Day\',' . $t->dateString() . ');')) . ($i + 1) . '.</a>';
         $hours_html .= sprintf('<th width="%s%%">%s</th>', $dayWidth, $day_label);
     }
     for ($i = 0; $i < $this->_days; $i++) {
         $start = new Horde_Date(array('hour' => $this->_startHour, 'month' => $this->_start->month, 'mday' => $this->_start->mday + $i, 'year' => $this->_start->year));
         $end = new Horde_Date(array('hour' => $this->_endHour, 'month' => $this->_start->month, 'mday' => $this->_start->mday + $i, 'year' => $this->_start->year));
         $this->_timeBlocks[] = array($start, $end);
     }
     return $hours_html;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:29,代码来源:Month.php

示例2: getWeekOfYear

 /**
  * Gets the week of the year for this date
  *
  * Gets the week of the year for this date
  *
  * @access public
  * @return int the week of the year
  */
 function getWeekOfYear()
 {
     return Date_Calc::weekOfYear($this->day, $this->month, $this->year);
 }
开发者ID:mickdane,项目名称:zidisha,代码行数:12,代码来源:Date.php

示例3: showWeeks

function showWeeks()
{
    global $allocated_hours_sum, $end_date, $start_date, $AppUI, $user_list, $user_names, $user_usage, $hideNonWd, $table_header, $table_rows, $df, $working_days_count, $total_hours_capacity, $total_hours_capacity_all;
    $working_days_count = 0;
    $allocated_hours_sum = 0;
    $ed = new CDate(Date_Calc::endOfWeek($end_date->day, $end_date->month, $end_date->year));
    $sd = new CDate(Date_Calc::beginOfWeek($start_date->day, $start_date->month, $start_date->year));
    $week_difference = ceil($ed->workingDaysInSpan($sd) / count(explode(",", dPgetConfig("cal_working_days"))));
    $actual_date = $sd;
    $table_header = "<tr><th>" . $AppUI->_("User") . "</th>";
    for ($i = 0; $i < $week_difference; $i++) {
        $table_header .= "<th>" . Date_Calc::weekOfYear($actual_date->day, $actual_date->month, $actual_date->year) . "<br><table><td style='font-weight:normal; font-size:70%'>" . $actual_date->format($df) . "</td></table></th>";
        $actual_date->addSeconds(168 * 3600);
        // + one week
    }
    $table_header .= "<th nowrap='nowrap' colspan='2'>" . $AppUI->_("Allocated") . "</th></tr>";
    $table_rows = "";
    foreach ($user_list as $user_id => $user_data) {
        @($user_names[$user_id] = $user_data["user_username"]);
        if (isset($user_usage[$user_id])) {
            $table_rows .= "<tr><td nowrap='nowrap'>(" . $user_data["user_username"] . ") " . $user_data["contact_first_name"] . " " . $user_data["contact_last_name"] . "</td>";
            $actual_date = $sd;
            for ($i = 0; $i < $week_difference; $i++) {
                $awoy = $actual_date->year . Date_Calc::weekOfYear($actual_date->day, $actual_date->month, $actual_date->year);
                $table_rows .= "<td align='right'>";
                if (isset($user_usage[$user_id][$awoy])) {
                    $hours = number_format($user_usage[$user_id][$awoy], 2);
                    $table_rows .= $hours;
                    $percentage_used = round($hours / (dPgetConfig("daily_working_hours") * count(explode(",", dPgetConfig("cal_working_days")))) * 100);
                    $bar_color = "blue";
                    if ($percentage_used > 100) {
                        $bar_color = "red";
                        $percentage_used = 100;
                    }
                    $table_rows .= "<div style='height:2px;width:{$percentage_used}%; background-color:{$bar_color}'>&nbsp;</div>";
                } else {
                    $table_rows .= "&nbsp;";
                }
                $table_rows .= "</td>";
                $actual_date->addSeconds(168 * 3600);
                // + one week
            }
            $array_sum = array_sum($user_usage[$user_id]);
            $average_user_usage = number_format($array_sum / ($week_difference * count(explode(",", dPgetConfig("cal_working_days"))) * dPgetConfig("daily_working_hours")) * 100, 2);
            $allocated_hours_sum += $array_sum;
            $bar_color = "blue";
            if ($average_user_usage > 100) {
                $bar_color = "red";
                $average_user_usage = 100;
            }
            $table_rows .= "<td ><div align='left'>" . round($array_sum, 2) . " " . $AppUI->_("hours") . "</td> <td align='right'> " . $average_user_usage;
            $table_rows .= "%</div>";
            $table_rows .= "<div align='left' style='height:2px;width:{$average_user_usage}%; background-color:{$bar_color}'>&nbsp;</div></td>";
            $table_rows .= "</tr>";
        }
    }
    $total_hours_capacity = $week_difference * count(explode(",", dPgetConfig("cal_working_days"))) * dPgetConfig("daily_working_hours") * count($user_usage);
    $total_hours_capacity_all = $week_difference * count(explode(",", dPgetConfig("cal_working_days"))) * dPgetConfig("daily_working_hours") * count($user_list);
}
开发者ID:n2i,项目名称:xvnkb,代码行数:59,代码来源:allocateduserhours.php

示例4: dateFormat

 /**
  *  Formats the date in the given format, much like
  *  strfmt(). This function is used to alleviate the
  *  problem with 32-bit numbers for dates pre 1970
  *  or post 2038, as strfmt() has on most systems.
  *  Most of the formatting options are compatible.
  *
  *  formatting options:
  *
  *  %a        abbreviated weekday name (Sun, Mon, Tue)
  *  %A        full weekday name (Sunday, Monday, Tuesday)
  *  %b        abbreviated month name (Jan, Feb, Mar)
  *  %B        full month name (January, February, March)
  *  %d        day of month (range 00 to 31)
  *  %e        day of month, single digit (range 0 to 31)
  *  %E        number of days since unspecified epoch (integer)
  *             (%E is useful for passing a date in a URL as
  *             an integer value. Then simply use
  *             daysToDate() to convert back to a date.)
  *  %j        day of year (range 001 to 366)
  *  %m        month as decimal number (range 1 to 12)
  *  %n        newline character (\n)
  *  %t        tab character (\t)
  *  %w        weekday as decimal (0 = Sunday)
  *  %U        week number of current year, first sunday as first week
  *  %y        year as decimal (range 00 to 99)
  *  %Y        year as decimal including century (range 0000 to 9999)
  *  %%        literal '%'
  *
  * @param string year in format CCYY
  * @param string month in format MM
  * @param string day in format DD
  * @param string format for returned date
  *
  * @access public
  *
  * @return string date in given format
  */
 function dateFormat($day, $month, $year, $format)
 {
     if (!Date_Calc::isValidDate($day, $month, $year)) {
         $year = Date_Calc::dateNow("%Y");
         $month = Date_Calc::dateNow("%m");
         $day = Date_Calc::dateNow("%d");
     }
     $output = "";
     for ($strpos = 0; $strpos < strlen($format); $strpos++) {
         $char = substr($format, $strpos, 1);
         if ($char == "%") {
             $nextchar = substr($format, $strpos + 1, 1);
             switch ($nextchar) {
                 case "a":
                     $output .= Date_Calc::getWeekdayAbbrname($day, $month, $year);
                     break;
                 case "A":
                     $output .= Date_Calc::getWeekdayFullname($day, $month, $year);
                     break;
                 case "b":
                     $output .= Date_Calc::getMonthAbbrname($month);
                     break;
                 case "B":
                     $output .= Date_Calc::getMonthFullname($month);
                     break;
                 case "d":
                     $output .= sprintf("%02d", $day);
                     break;
                 case "e":
                     $output .= $day;
                     break;
                 case "E":
                     $output .= Date_Calc::dateToDays($day, $month, $year);
                     break;
                 case "j":
                     $output .= Date_Calc::julianDate($day, $month, $year);
                     break;
                 case "m":
                     $output .= sprintf("%02d", $month);
                     break;
                 case "n":
                     $output .= "\n";
                     break;
                 case "t":
                     $output .= "\t";
                     break;
                 case "w":
                     $output .= Date_Calc::dayOfWeek($day, $month, $year);
                     break;
                 case "U":
                     $output .= Date_Calc::weekOfYear($day, $month, $year);
                     break;
                 case "y":
                     $output .= substr($year, 2, 2);
                     break;
                 case "Y":
                     $output .= $year;
                     break;
                 case "%":
                     $output .= "%";
                     break;
                 default:
//.........这里部分代码省略.........
开发者ID:noikiy,项目名称:owaspbwa,代码行数:101,代码来源:Calc.php

示例5: getWeekNInYear

 /**
  * Returns the number of the week in the year (ISO-8601), given a date
  * @param int year (2003)
  * @param int month (9)
  * @param int 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!
 }
开发者ID:BackupTheBerlios,项目名称:phpalmanac-svn,代码行数:13,代码来源:PearDate.php

示例6: dateFormat

 /**
  * Formats the date in the given format, much like strfmt()
  *
  * This function is used to alleviate the problem with 32-bit numbers for
  * dates pre 1970 or post 2038, as strfmt() has on most systems.
  * Most of the formatting options are compatible.
  *
  * Formatting options:
  * <pre>
  * %a   abbreviated weekday name (Sun, Mon, Tue)
  * %A   full weekday name (Sunday, Monday, Tuesday)
  * %b   abbreviated month name (Jan, Feb, Mar)
  * %B   full month name (January, February, March)
  * %d   day of month (range 00 to 31)
  * %e   day of month, single digit (range 0 to 31)
  * %E   number of days since unspecified epoch (integer)
  *        (%E is useful for passing a date in a URL as
  *        an integer value. Then simply use
  *        daysToDate() to convert back to a date.)
  * %j   day of year (range 001 to 366)
  * %m   month as decimal number (range 1 to 12)
  * %n   newline character (\n)
  * %t   tab character (\t)
  * %w   weekday as decimal (0 = Sunday)
  * %U   week number of current year, first sunday as first week
  * %y   year as decimal (range 00 to 99)
  * %Y   year as decimal including century (range 0000 to 9999)
  * %%   literal '%'
  * </pre>
  *
  * @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.
  * @param string $format the format string
  *
  * @return   string     the date in the desired format
  * @access   public
  * @static
  */
 function dateFormat($day, $month, $year, $format)
 {
     if (!Date_Calc::isValidDate($day, $month, $year)) {
         $year = Date_Calc::dateNow('%Y');
         $month = Date_Calc::dateNow('%m');
         $day = Date_Calc::dateNow('%d');
     }
     $output = '';
     for ($strpos = 0; $strpos < strlen($format); $strpos++) {
         $char = substr($format, $strpos, 1);
         if ($char == '%') {
             $nextchar = substr($format, $strpos + 1, 1);
             switch ($nextchar) {
                 case 'a':
                     $output .= Date_Calc::getWeekdayAbbrname($day, $month, $year);
                     break;
                 case 'A':
                     $output .= Date_Calc::getWeekdayFullname($day, $month, $year);
                     break;
                 case 'b':
                     $output .= Date_Calc::getMonthAbbrname($month);
                     break;
                 case 'B':
                     $output .= Date_Calc::getMonthFullname($month);
                     break;
                 case 'd':
                     $output .= sprintf('%02d', $day);
                     break;
                 case 'e':
                     $output .= $day;
                     break;
                 case 'E':
                     $output .= Date_Calc::dateToDays($day, $month, $year);
                     break;
                 case 'j':
                     $output .= Date_Calc::dayOfYear($day, $month, $year);
                     break;
                 case 'm':
                     $output .= sprintf('%02d', $month);
                     break;
                 case 'n':
                     $output .= "\n";
                     break;
                 case 't':
                     $output .= "\t";
                     break;
                 case 'w':
                     $output .= Date_Calc::dayOfWeek($day, $month, $year);
                     break;
                 case 'U':
                     $output .= Date_Calc::weekOfYear($day, $month, $year);
                     break;
                 case 'y':
                     $output .= sprintf('%0' . ($year < 0 ? '3' : '2') . 'd', $year % 100);
                     break;
                 case "Y":
                     $output .= sprintf('%0' . ($year < 0 ? '5' : '4') . 'd', $year);
                     break;
                 case '%':
                     $output .= '%';
//.........这里部分代码省略.........
开发者ID:222elm,项目名称:dotprojectFrame,代码行数:101,代码来源:Calc.php

示例7: userUsageWeeks

function userUsageWeeks()
{
    global $task_start_date, $task_end_date, $day_difference, $hours_added, $actual_date, $users, $user_data, $user_usage, $use_assigned_percentage, $user_tasks_counted_in, $task, $start_date, $end_date;
    $task_duration_per_week = $task->getTaskDurationPerWeek($use_assigned_percentage);
    $ted = new CDate(Date_Calc::endOfWeek($task_end_date->day, $task_end_date->month, $task_end_date->year));
    $tsd = new CDate(Date_Calc::beginOfWeek($task_start_date->day, $task_start_date->month, $task_start_date->year));
    $ed = new CDate(Date_Calc::endOfWeek($end_date->day, $end_date->month, $end_date->year));
    $sd = new CDate(Date_Calc::beginOfWeek($start_date->day, $start_date->month, $start_date->year));
    $week_difference = $end_date->workingDaysInSpan($start_date) / count(explode(",", dPgetConfig("cal_working_days")));
    $actual_date = $start_date;
    for ($i = 0; $i <= $week_difference; $i++) {
        if (!$actual_date->before($tsd) && !$actual_date->after($ted)) {
            $awoy = $actual_date->year . Date_Calc::weekOfYear($actual_date->day, $actual_date->month, $actual_date->year);
            foreach ($users as $user_id => $user_data) {
                if (!isset($user_usage[$user_id][$awoy])) {
                    $user_usage[$user_id][$awoy] = 0;
                }
                $percentage_assigned = $use_assigned_percentage ? $user_data["perc_assignment"] / 100 : 1;
                $hours_added = $task_duration_per_week * $percentage_assigned;
                $user_usage[$user_id][$awoy] += $hours_added;
                if ($user_usage[$user_id][$awoy] < 0.005) {
                    //We want to show at least 0.01 even when the assigned time is very small so we know
                    //that at that time the user has a running task
                    $user_usage[$user_id][$awoy] += 0.006;
                    $hours_added += 0.006;
                }
                // Let's register the tasks counted in for calculation
                if (!array_key_exists($user_id, $user_tasks_counted_in)) {
                    $user_tasks_counted_in[$user_id] = array();
                }
                if (!array_key_exists($task->task_project, $user_tasks_counted_in[$user_id])) {
                    $user_tasks_counted_in[$user_id][$task->task_project] = array();
                }
                if (!array_key_exists($task->task_id, $user_tasks_counted_in[$user_id][$task->task_project])) {
                    $user_tasks_counted_in[$user_id][$task->task_project][$task->task_id] = 0;
                }
                // We add it up
                $user_tasks_counted_in[$user_id][$task->task_project][$task->task_id] += $hours_added;
            }
        }
        $actual_date->addSeconds(168 * 3600);
        // + one week
    }
}
开发者ID:magsilva,项目名称:dotproject,代码行数:44,代码来源:allocateduserhours.php

示例8: EVLIST_monthview

/**
*   Display a monthly calendar.
*   Dates that have events scheduled are highlighted.
*
*   @param  integer $year   Year to display, default is current year
*   @param  integer $month  Starting month
*   @param  integer $day    Starting day
*   @param  integer $cat    Event category
*   @plaram integer $cal    Calendar ID
*   @return string          HTML for calendar page
*/
function EVLIST_monthview($year = 0, $month = 0, $day = 0, $cat = 0, $cal = 0, $opt = '')
{
    global $_CONF, $_EV_CONF, $LANG_MONTH;
    EVLIST_setViewSession('month', $year, $month, $day);
    $retval = '';
    list($currentyear, $currentmonth, $currentday) = explode('-', $_EV_CONF['_today']);
    // Default to the current month
    if ($year == 0) {
        $year = $currentyear;
    }
    if ($month == 0) {
        $month = $currentmonth;
    }
    if ($day == 0) {
        $day = $currentday;
    }
    $cat = (int) $cat;
    $cal = (int) $cal;
    // Set the calendar header.  Done early because the _can_add value is
    // set by this function
    $cal_header = EVLIST_calHeader($year, $month, $day, 'month', $cat, $cal);
    // Get all the dates in the month
    $calendarView = Date_Calc::getCalendarMonth($month, $year, '%Y-%m-%d');
    $x = count($calendarView) - 1;
    $y = count($calendarView[$x]) - 1;
    $starting_date = $calendarView[0][0];
    $ending_date = $calendarView[$x][$y];
    $daynames = EVLIST_getDayNames();
    $events = EVLIST_getEvents($starting_date, $ending_date, array('cat' => $cat, 'cal' => $cal));
    $nextmonth = $month + 1;
    $nextyear = $year;
    if ($nextmonth > 12) {
        $nextmonth = 1;
        $nextyear = $year + 1;
    }
    $prevmonth = $month - 1;
    $prevyear = $year;
    if ($prevmonth < 1) {
        $prevmonth = 12;
        $prevyear = $year - 1;
    }
    $tplpath = EVLIST_PI_PATH . '/templates/monthview';
    $tpl = 'monthview';
    if ($opt == 'print') {
        $tpl .= '_print';
    } elseif ($_EV_CONF['cal_tmpl'] == 'json') {
        $tpl .= '_json';
    }
    $T = new Template($tplpath);
    $T->set_file(array('monthview' => $tpl . '.thtml', 'allday_event' => 'event_allday.thtml', 'timed_event' => 'event_timed.thtml'));
    foreach ($daynames as $key => $dayname) {
        $T->set_var('dayname' . $key, $dayname);
    }
    list($y, $m, $d) = explode('-', $starting_date);
    $weekOfYear = Date_Calc::weekOfYear($d, $m, $y);
    $calendars_used = array();
    $i = 0;
    $T->set_block('monthview', 'weekBlock', 'wBlock');
    foreach ($calendarView as $weeknum => $weekdata) {
        list($weekYear, $weekMonth, $weekDay) = explode('-', $weekdata[0]);
        $T->set_var(array('wyear' => $weekYear, 'wmonth' => $weekMonth, 'wday' => $weekDay, 'urlfilt_cat' => $cat, 'urlfilt_cal' => $cal, 'weeknum' => $weekOfYear, $tplx => 'true'));
        $weekOfYear++;
        foreach ($weekdata as $daynum => $daydata) {
            list($y, $m, $d) = explode('-', $daydata);
            if ($daydata == $_EV_CONF['_today']) {
                $dayclass = 'today';
            } elseif ($m == $month) {
                $dayclass = 'on';
            } else {
                $dayclass = 'off';
            }
            $T->set_var('cal_day_anchortags', COM_createLink(sprintf("%02d", $d), EVLIST_URL . '/index.php?view=day&amp;' . "cat={$cat}&amp;cal={$cal}" . "&amp;day={$d}&amp;month={$m}&amp;year={$y}", array('class' => 'cal-date')));
            if (!isset($events[$daydata])) {
                // Just to avoid foreach() errors
                $events[$daydata] = array();
            }
            $dayentries = '';
            $T->clear_var('cal_day_entries');
            $T->set_block('monthview', 'dayBlock', 'dBlock');
            foreach ($events[$daydata] as $event) {
                if (empty($event['title'])) {
                    continue;
                }
                $ev_hover = '';
                // Sanitize fields for display.  No HTML in the popup.
                $title = htmlentities(strip_tags($event['title']));
                $summary = htmlentities(strip_tags($event['summary']));
                // add the calendar to the array to create the JS checkboxes
                $calendars_used[$event['cal_id']] = array('cal_name' => $event['cal_name'], 'cal_ena_ical' => $event['cal_ena_ical'], 'cal_id' => $event['cal_id'], 'fgcolor' => $event['fgcolor'], 'bgcolor' => $event['bgcolor']);
//.........这里部分代码省略.........
开发者ID:matrox66,项目名称:evlist,代码行数:101,代码来源:evlist_views.inc.php

示例9: compare

compare('Sat', Date_Calc::getWeekdayAbbrname(1, 1, 2005), 'getWeekdayAbbrname');
compare(11, Date_Calc::getMonthFromFullName('November'), 'getMonthFromFullName');
compare(327, Date_Calc::dayOfYear('22', '11', '2000'), 'dayOfYear str');
compare('November', Date_Calc::getMonthFullname('11'), 'getMonthFullname str');
compare('Nov', Date_Calc::getMonthAbbrname('11'), 'getMonthAbbrname str');
compare('Saturday', Date_Calc::getWeekdayFullname('01', '01', '2005'), 'getWeekdayFullname str');
compare('Sat', Date_Calc::getWeekdayAbbrname('01', '01', '2005'), 'getWeekdayAbbrname str');
$exp = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
compare($exp, Date_Calc::getMonthNames(), 'getMonthNames');
$exp = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
compare($exp, Date_Calc::getWeekDays(), 'getWeekDays');
compare(3, Date_Calc::dayOfWeek(22, 11, 2000), 'dayOfWeek');
compare(47, Date_Calc::weekOfYear(22, 11, 2000), 'weekOfYear');
compare(4, Date_Calc::quarterOfYear(22, 11, 2000), 'quarterOfYear');
compare(3, Date_Calc::dayOfWeek('22', '11', '2000'), 'dayOfWeek str');
compare(47, Date_Calc::weekOfYear('22', '11', '2000'), 'weekOfYear str');
compare(4, Date_Calc::quarterOfYear('22', '11', '2000'), 'quarterOfYear str');
compare(28, Date_Calc::daysInMonth(2, 1900), 'daysInMonth 1');
compare(29, Date_Calc::daysInMonth(2, 1996), 'daysInMonth 2');
compare(29, Date_Calc::daysInMonth(2, 2000), 'daysInMonth 3');
compare(28, Date_Calc::daysInMonth(2, 2001), 'daysInMonth 4');
compare(30, Date_Calc::daysInMonth(11, 2000), 'daysInMonth 5');
compare(28, Date_Calc::daysInMonth('02', 1900), 'daysInMonth 1 str');
compare(29, Date_Calc::daysInMonth('02', 1996), 'daysInMonth 2 str');
compare(29, Date_Calc::daysInMonth('02', 2000), 'daysInMonth 3 str');
compare(28, Date_Calc::daysInMonth('02', 2001), 'daysInMonth 4 str');
compare(30, Date_Calc::daysInMonth('11', '2000'), 'daysInMonth 5 str');
compare(5, Date_Calc::weeksInMonth(11, 2000), 'weeksInMonth');
compare(5, Date_Calc::weeksInMonth('11', '2000'), 'weeksInMonth str');
$exp = array('19000226', '19000227', '19000228', '19000301', '19000302', '19000303', '19000304');
compare($exp, Date_Calc::getCalendarWeek(27, 2, 1900), 'getCalendarWeek 1');
开发者ID:MagnusA,项目名称:Date,代码行数:31,代码来源:calc.php

示例10: explode

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 = 2 == Date_Calc::weekOfYear(5, 1, 1998) ? true : false;
$pass2 = 2 == Date_Calc::weekOfYear(6, 1, 1998) ? true : false;
$pass3 = 2 == Date_Calc::weekOfYear(5, 1, 2004) ? true : false;
$pass4 = 2 == Date_Calc::weekOfYear(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:Artea,项目名称:freebeer,代码行数:31,代码来源:test_calc.php


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