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


PHP Date::getDayOfWeek方法代码示例

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


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

示例1: elseif

 /**
  * Calculate Nth day of the week in a month
  *
  * @param int $position position
  * @param int $weekday  day of the week starting from 1 == sunday
  * @param int $month    month
  *
  * @access   private
  * @return   object Date date
  */
 function _calcNthWeekDayInMonth($position, $weekday, $month)
 {
     if ($position == 1) {
         $startday = '01';
     } elseif ($position == 2) {
         $startday = '08';
     } elseif ($position == 3) {
         $startday = '15';
     } elseif ($position == 4) {
         $startday = '22';
     } elseif ($position == 5) {
         $startday = '29';
     }
     $month = sprintf("%02d", $month);
     $date = new Date($this->_year . '-' . $month . '-' . $startday);
     while ($date->getDayOfWeek() != $weekday) {
         $date = $date->getNextDay();
     }
     return $date;
 }
开发者ID:Raithlin,项目名称:web2project-holiday,代码行数:30,代码来源:Brazil.php

示例2: get_weekly_volume_graph

function get_weekly_volume_graph()
{
    global $wpdb;
    global $userdata;
    get_currentuserinfo();
    $beg_date = new Date();
    $end_date = new Date();
    $wk = array(0, 0, 0, 0);
    $label = array(0, 0, 0, 0);
    $filename = array("filename" => "/var/www/vanhlebarsoftware/wp-content/plugins/fitnesslog/graphs/wklygraph.png");
    // Get current weeks and prior three weeks volume numbers.
    $day_of_wk = $beg_date->getDayOfWeek();
    $beg_date->addDays(-($day_of_wk - 1));
    $end_date->copy($beg_date);
    $end_date->addDays(6);
    for ($i = 0; $i < 4; $i++) {
        $query = "SELECT user_id, SUM(seconds) AS seconds FROM " . $wpdb->prefix . "flmain WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userdata->ID . " GROUP BY user_id";
        $result = $wpdb->get_results($query, ARRAY_A);
        if ($result) {
            foreach ($result as $row) {
                $wk[$i] = convert_seconds_minutes($row["seconds"]);
            }
        } else {
            $wk[$i] = 0;
        }
        // Add any strength training that we have done to the total.
        $query = "SELECT user_id, SUM(seconds) AS seconds FROM " . $wpdb->prefix . "flstrength WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userdata->ID . " GROUP BY user_id";
        $result = $wpdb->get_results($query, ARRAY_A);
        if ($result) {
            foreach ($result as $row) {
                $wk[$i] = $wk[$i] + convert_seconds_minutes($row["seconds"]);
            }
        }
        // Create the labels.
        $label[$i] = $end_date->format("%m/%d");
        // Move the dates back by one week.
        $beg_date->addDays(-7);
        $end_date->addDays(-7);
    }
    //Setup the graph.
    $Graph =& Image_Graph::factory('graph', array(175, 175), true);
    $Plotarea =& $Graph->addNew('plotarea');
    $Dataset =& Image_Graph::factory('dataset');
    $Dataset->addPoint($label[3], $wk[3]);
    $Dataset->addPoint($label[2], $wk[2]);
    $Dataset->addPoint($label[1], $wk[1]);
    $Dataset->addPoint($label[0], $wk[0]);
    $Plot =& $Plotarea->addNew('bar', &$Dataset);
    $Plot->setFillColor('green');
    $YAxis =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
    $YAxis->setTitle('Minutes', 'vertical');
    $XAxis =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
    //	$XAxis->setFontAngle( "vertical" );
    $XAxis->setTitle("Week", array('angle' => 0));
    //Output the finished graph to the graphs directory.
    $result = $Graph->done($filename);
    if ($result) {
        var_dump("error creating graph!");
    }
}
开发者ID:EABonney,项目名称:Fitlog,代码行数:60,代码来源:fitnesslog.php

示例3: Date


//.........这里部分代码省略.........
     $this->_addHoliday('unPeaceSquadsDay', $this->_year . '-05-29', 'International UN Peace Squads\' Day');
     /**
      * World's Nonsmokers' Day
      */
     $this->_addHoliday('nonsmokersDay', $this->_year . '-05-31', 'World\'s Nonsmokers\' Day');
     /**
      * World's Agriculturalists' Day
      */
     $this->_addHoliday('farmersDay', $this->_year . '-06-01', 'World\'s Agriculturalists\' Day');
     /**
      * World's Environment Day
      */
     $this->_addHoliday('environmentDay', $this->_year . '-06-05', 'World\'s Environment Day');
     /**
      * African Children's Day
      */
     $this->_addHoliday('africanChildrenDay', $this->_year . '-06-16', 'African Children\'s Day');
     /**
      * World's Desert's Day
      */
     $this->_addHoliday('desertDay', $this->_year . '-06-17', 'World\'s Desert\'s Day');
     /**
      * African Fugitives' Day
      */
     $this->_addHoliday('africanFugitiveDay', $this->_year . '-06-20', 'African Fugitives\' Day');
     /**
      * International day against drugs
      */
     $this->_addHoliday('antiDrugsDay', $this->_year . '-06-26', 'International day against drugs');
     /**
      * International Cooperative Societies' Day
      */
     $coopDayDate = new Date($this->_year . '-07-01');
     while ($coopDayDate->getDayOfWeek() != 6) {
         $coopDayDate = $coopDayDate->getNextDay();
     }
     $this->_addHoliday('intCoopDay', $coopDayDate, 'International Cooperative Societies\' Day');
     /**
      * World's Population Day
      */
     $this->_addHoliday('populationDay', $this->_year . '-07-11', 'World\'s Population Day');
     /**
      * International day of indigenous people
      */
     $this->_addHoliday('indigenousPeopleDay', $this->_year . '-08-09', 'International day of indigenous people');
     /**
      * International Youth' Day
      */
     $this->_addHoliday('intYouthDay', $this->_year . '-08-12', 'International Youth\' Day');
     /**
      * International day of slave trade's abolishment
      */
     $this->_addHoliday('slaveTradeDay', $this->_year . '-08-23', 'International day of slave trade\'s abolishment');
     /**
      * World's Alphabetization Day
      */
     $this->_addHoliday('alphabetizationDay', $this->_year . '-09-08', 'World\'s Alphabetization Day');
     /**
      * Ozone Layer's Protection Day
      */
     $this->_addHoliday('ozoneLayerProtectionDay', $this->_year . '-09-16', 'Ozone Layer\'s Protection Day');
     /**
      * International day of peace
      */
     $peaceDayDate = new Date($this->_year . '-09-01');
     while ($peaceDayDate->getDayOfWeek() != 2) {
开发者ID:slawekmikula,项目名称:dotproject,代码行数:67,代码来源:UNO.php

示例4: get_weekly_volume_graph

function get_weekly_volume_graph($userID, $connection)
{
    $beg_date = new Date();
    $end_date = new Date();
    $wk = array(0, 0, 0, 0, 0, 0, 0);
    $wk_actual = array(0, 0, 0, 0, 0, 0, 0);
    $label = array(0, 0, 0, 0, 0, 0, 0);
    $filename = array("filename" => "/var/www/vanhlebarsoftware/fitlog/graphs/wklygraph.jpg");
    // Get current weeks and prior three weeks volume numbers and the next three weeks.
    $day_of_wk = $beg_date->getDayOfWeek();
    $beg_date->addDays(-($day_of_wk - 1) + 21);
    $end_date->copy($beg_date);
    $end_date->addDays(6);
    for ($i = 0; $i < 7; $i++) {
        // Get the planned volume for this particular week.
        $query = "SELECT SUM(seconds) AS seconds FROM flmain WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userID . " AND plan_type='p'";
        $queryStr = "SELECT SUM(seconds) AS seconds FROM flstrength WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userID . " AND plan_type='p'";
        $result = @mysql_query($query, $connection);
        $resultStr = @mysql_query($query, $connection);
        if ($result || $resultStr) {
            $tmp = 0;
            if ($result) {
                $row = mysql_fetch_array($result);
                $tmp = convert_seconds_minutes($row["seconds"]);
            }
            if ($resultStr) {
                $rowStr = mysql_fetch_array($resultStr);
                $tmp += convert_seconds_minutes($rowStr["seconds"]);
            }
            $wk[$i] = $tmp;
        } else {
            $wk[$i] = 0;
        }
        // Get the actual volume for this particular week.
        $query = "SELECT SUM(seconds) AS seconds FROM flmain WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userID . " AND plan_type='a'";
        $queryStr = "SELECT SUM(seconds) AS seconds FROM flstrength WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userID . " AND plan_type='a'";
        $result = @mysql_query($query, $connection);
        $resultStr = @mysql_query($queryStr, $connection);
        if ($result || $resultStr) {
            $tmp = 0;
            if ($result) {
                $row = mysql_fetch_array($result);
                $tmp = convert_seconds_minutes($row["seconds"]);
            }
            if ($resultStr) {
                $rowStr = mysql_fetch_array($resultStr);
                $tmp += convert_seconds_minutes($rowStr["seconds"]);
            }
            $wk_actual[$i] = $tmp;
        } else {
            $wk_actual[$i] = 0;
        }
        // Create the labels.
        $label[$i] = $end_date->format("%m/%d");
        // Move the dates back by one week.
        $beg_date->addDays(-7);
        $end_date->addDays(-7);
    }
    for ($i = 0; $i < 7; $i++) {
    }
    //Setup the graph.
    $Graph =& Image_Graph::factory('graph', array(300, 210, TRUE));
    $Graph->add(Image_Graph::factory('title', array('Weekly Volume - Actual vs. Planned'), 12));
    $Plotarea =& $Graph->addNew('plotarea');
    $Dataset =& Image_Graph::factory('dataset');
    $Dataset1 =& Image_Graph::factory('dataset');
    // Add the actual volume to the graph.
    $Dataset1->addPoint($label[6], $wk_actual[6]);
    $Dataset1->addPoint($label[5], $wk_actual[5]);
    $Dataset1->addPoint($label[4], $wk_actual[4]);
    $Dataset1->addPoint($label[3], $wk_actual[3]);
    $Dataset1->addPoint($label[2], $wk_actual[2]);
    $Dataset1->addPoint($label[1], $wk_actual[1]);
    $Dataset1->addPoint($label[0], $wk_actual[0]);
    // Add the planned volume to the graph.
    $Dataset->addPoint($label[6], $wk[6]);
    $Dataset->addPoint($label[5], $wk[5]);
    $Dataset->addPoint($label[4], $wk[4]);
    $Dataset->addPoint($label[3], $wk[3]);
    $Dataset->addPoint($label[2], $wk[2]);
    $Dataset->addPoint($label[1], $wk[1]);
    $Dataset->addPoint($label[0], $wk[0]);
    // Plot the actual data to the graph.
    $Plot =& $Plotarea->addNew('line', &$Dataset);
    $Plot1 =& $Plotarea->addNew('bar', &$Dataset1);
    $Plot1->setFillColor('green@.8');
    // Set the axis titles.
    $YAxis =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
    $YAxis->setTitle('Minutes', 'vertical');
    $XAxis =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
    $XAxis->setTitle("Week", array('angle' => 0));
    //Output the finished graph to the graphs directory.
    $result = $Graph->done($filename);
    if ($result) {
        var_dump("error creating graph!");
    }
}
开发者ID:EABonney,项目名称:Fitlog,代码行数:97,代码来源:dashboard.php

示例5: array

 /**
  * DB_DataObject_FormBuilder::_date2array()
  *
  * Takes a string representing a date or a unix timestamp and turns it into an
  * array suitable for use with the QuickForm data element.
  * When using a string, make sure the format can be handled by the PEAR::Date constructor!
  *
  * Beware: For the date conversion to work, you must at least use the letters "d", "m" and "Y" in
  * your format string (see "dateElementFormat" option). If you want to enter a time as well,
  * you will have to use "H", "i" and "s" as well. Other letters will not work! Exception: You can
  * also use "M" instead of "m" if you want plain text month names.
  *
  * @param mixed $date   A unix timestamp or the string representation of a date, compatible to strtotime()
  * @return array
  * @access protected
  */
 function _date2array($date)
 {
     $da = array();
     if (is_string($date)) {
         // Get PEAR::Date class definition, if needed
         include_once 'Date.php';
         $dObj = new Date($date);
         $da['d'] = $dObj->getDay();
         $da['l'] = $da['D'] = $dObj->getDayOfWeek();
         $da['m'] = $da['M'] = $da['F'] = $dObj->getMonth();
         $da['Y'] = $da['y'] = $dObj->getYear();
         $da['H'] = $dObj->getHour();
         $da['h'] = $da['H'] % 12;
         if ($da['h'] == 0) {
             $da['h'] = 12;
         }
         $da['i'] = $dObj->getMinute();
         $da['s'] = $dObj->getSecond();
         if ($da['H'] >= 12) {
             $da['a'] = 'pm';
             $da['A'] = 'PM';
         } else {
             $da['a'] = 'am';
             $da['A'] = 'AM';
         }
         unset($dObj);
     } else {
         if (is_int($date)) {
             $time = $date;
         } else {
             $time = time();
         }
         $da['d'] = date('d', $time);
         $da['l'] = $da['D'] = date('w', $time);
         $da['m'] = $da['M'] = $da['F'] = date('m', $time);
         $da['Y'] = $da['y'] = date('Y', $time);
         $da['H'] = date('H', $time);
         $da['h'] = date('h', $time);
         $da['i'] = date('i', $time);
         $da['s'] = date('s', $time);
         $da['a'] = date('a', $time);
         $da['A'] = date('A', $time);
     }
     $this->debug('<i>_date2array():</i> from ' . $date . ' ...');
     return $da;
 }
开发者ID:GeekyNinja,项目名称:LifesavingCAD,代码行数:62,代码来源:FormBuilder.php

示例6: prepareWeekBreakdown

 /**
  * A method to modify an array of history data so that it can be displayed in a format
  * compatible with the weekly breakdown template.
  *
  * @param array $aData    A reference to an array of arrays, containing the rows of data.
  * @param object $oCaller The calling object. Expected to have the the class variable
  *                        "statsBreakdown" set.
  */
 function prepareWeekBreakdown(&$aData, $oCaller)
 {
     // Only prepare the weekly breakdown if the statsBreakdown
     // in the caller is set to "week"
     if ($oCaller->statsBreakdown != 'week') {
         return;
     }
     $beginOfWeek = OA_Admin_DaySpan::getBeginOfWeek();
     $aWeekData = array();
     ksort($aData);
     foreach ($aData as $key => $aRowData) {
         // Get the date for this row's data
         $oDate = new Date($key);
         if ($beginOfWeek != 0) {
             // Need to change the date used for the data so
             // that the day appears in the correct week
             $daysToGoback = (int) (SECONDS_PER_DAY * $beginOfWeek);
             $oDate->subtractSeconds($daysToGoback);
         }
         // Get the week this date is in, in YYYY-MM format
         $week = sprintf('%04d-%02d', $oDate->getYear(), $oDate->getWeekOfYear());
         // Prepare the data array for this week, if not set, where
         // the week is in the "week" index, there is a "data" index
         // for all the rows that make up the week, and the array
         // has all the columns of an empty data row
         if (!isset($aWeekData[$week])) {
             $aWeekData[$week] = $oCaller->aEmptyRow;
             $aWeekData[$week]['week'] = $week;
             $aWeekData[$week]['data'] = array();
         }
         // Add the data from the row to the totals of the week
         foreach (array_keys($oCaller->aColumns) as $colKey) {
             $aWeekData[$week][$colKey] += $aRowData[$colKey];
         }
         // Store the row in the week
         $aWeekData[$week]['data'][$key] = $aRowData;
     }
     foreach (array_keys($aWeekData) as $week) {
         // Now that the totals are complete, fill any
         // remaining days in the week with empty data
         $days = count($aWeekData[$week]['data']);
         if ($days < 7) {
             // Locate the first day of the week in the days that make
             // up the week so far
             ksort($aWeekData[$week]['data']);
             $key = key($aWeekData[$week]['data']);
             $oDate = new Date($key);
             $firstDataDayOfWeek = $oDate->getDayOfWeek();
             // Is this after the start of the week?
             if ($firstDataDayOfWeek > $beginOfWeek) {
                 // Change the date to be the first day of this week
                 $daysToGoback = (int) (SECONDS_PER_DAY * ($firstDataDayOfWeek - $beginOfWeek));
                 $oDate->subtractSeconds($daysToGoback);
             }
             // Check each day in the week
             for ($counter = 0; $counter < 7; $counter++) {
                 if (is_null($aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')])) {
                     // Set the day's data to the empty row, plus the "day" heading for the day
                     $aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')] = $oCaller->aEmptyRow;
                     $aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')]['day'] = $oDate->format($GLOBALS['date_format']);
                 } elseif (!is_null($aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')]) && !array_key_exists('day', $aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')])) {
                     $aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')]['day'] = $oDate->format($GLOBALS['date_format']);
                 }
                 $oDate->addSeconds(SECONDS_PER_DAY);
             }
         }
         // Ensure the day data is sorted correctly
         ksort($aWeekData[$week]['data']);
         // Format all day rows
         foreach (array_keys($aWeekData[$week]['data']) as $key) {
             $oCaller->_formatStatsRowRecursive($aWeekData[$week]['data'][$key]);
         }
         // Calculate CTR and other columns, making sure that the method is available
         if (is_callable(array($oCaller, '_summarizeStats'))) {
             $oCaller->_summarizeStats($aWeekData[$week]);
         }
     }
     // Set the new weekly-formatted data as the new data array to use
     $aData = $aWeekData;
 }
开发者ID:Apeplazas,项目名称:plazadelatecnologia,代码行数:88,代码来源:History.php

示例7: Date

 /**
  * Build the internal arrays that contain data about the calculated holidays
  *
  * @access   protected
  * @return   boolean true on success, otherwise a PEAR_ErrorStack object
  * @throws   object PEAR_ErrorStack
  */
 function _buildHolidays()
 {
     parent::_buildHolidays();
     $easterDate = $this->getHolidayDate('easter');
     $ashWednesdayDate = $this->getHolidayDate('ashWednesday');
     $ascensionDayDate = $this->getHolidayDate('ascensionDay');
     $advent1Date = $this->getHolidayDate('advent1');
     /**
      * New Year's Day
      */
     $this->_addHoliday('newYearsDay', $this->_year . '-01-01', 'New Year\'s Day');
     /**
      * Valentine's Day
      */
     $this->_addHoliday('valentinesDay', $this->_year . '-02-14', 'Valentine\'s Day');
     /**
      * "Weiberfastnacht"
      */
     $wFasnetDate = $this->_addDays($ashWednesdayDate, -6);
     $this->_addHoliday('womenFasnet', $wFasnetDate, 'Carnival');
     /**
      * Carnival / "Fastnacht"
      */
     $fasnetDate = $this->_addDays($easterDate, -47);
     $this->_addHoliday('fasnet', $fasnetDate, 'Carnival');
     /**
      * Rose Monday
      */
     $roseMondayDate = $this->_addDays($easterDate, -48);
     $this->_addHoliday('roseMonday', $roseMondayDate, 'Rose Monday');
     /**
      * International Women's Day
      */
     $this->_addHoliday('womensDay', $this->_year . '-03-08', 'International Women\'s Day');
     /**
      * April 1st
      */
     $this->_addHoliday('april1st', $this->_year . '-04-01', 'April 1st');
     /**
      * Girls' Day (fourth Thursday in April)
      */
     $girlsDayDate = new Date($this->_year . '-04-01');
     $dayOfWeek = $girlsDayDate->getDayOfWeek();
     switch ($dayOfWeek) {
         case 0:
         case 1:
         case 2:
         case 3:
             $girlsDayDate = $this->_addDays($girlsDayDate, 4 - $dayOfWeek + 21);
             break;
         case 4:
             $girlsDayDate = $this->_addDays($girlsDayDate, 21);
             break;
         case 5:
         case 6:
             $girlsDayDate = $this->_addDays($girlsDayDate, -1 * $dayOfWeek + 11 + 21);
             break;
     }
     $this->_addHoliday('girlsDay', $girlsDayDate, 'Girls\' Day');
     /**
      * International Earth' Day
      */
     $this->_addHoliday('earthDay', $this->_year . '-04-22', 'International Earth\' Day');
     /**
      * German Beer's Day
      */
     $this->_addHoliday('beersDay', $this->_year . '-04-23', 'German Beer\'s Day');
     /**
      * Walpurgis Night
      */
     $this->_addHoliday('walpurgisNight', $this->_year . '-04-30', 'Walpurgis Night');
     /**
      * Day of Work
      */
     $this->_addHoliday('dayOfWork', $this->_year . '-05-01', 'Day of Work');
     /**
      * World's Laughing Day
      */
     $laughingDayDate = new Date($this->_year . '-05-01');
     while ($laughingDayDate->getDayOfWeek() != 0) {
         $laughingDayDate = $laughingDayDate->getNextDay();
     }
     $this->_addHoliday('laughingDay', $laughingDayDate, 'World\'s Laughing Day');
     /**
      * Europe Day
      */
     $this->_addHoliday('europeDay', $this->_year . '-05-05', 'Europe Day');
     /**
      * Mothers' Day
      */
     $mothersDay = $this->_addDays($laughingDayDate, 7);
     $this->_addHoliday('mothersDay', $mothersDay, 'Mothers\' Day');
     /**
//.........这里部分代码省略.........
开发者ID:Raithlin,项目名称:web2project-holiday,代码行数:101,代码来源:Germany.php

示例8: array

 /**
  * DB_DataObject_FormBuilder::_date2array()
  *
  * Takes a string representing a date or a unix timestamp and turns it into an
  * array suitable for use with the QuickForm data element.
  * When using a string, make sure the format can be handled by the PEAR::Date constructor!
  *
  * Beware: For the date conversion to work, you must at least use the letters "d", "m" and "Y" in
  * your format string (see "dateElementFormat" option). If you want to enter a time as well,
  * you will have to use "H", "i" and "s" as well. Other letters will not work! Exception: You can
  * also use "M" instead of "m" if you want plain text month names.
  *
  * @param mixed $date   A unix timestamp or the string representation of a date, compatible to strtotime()
  * @return array
  * @access protected
  */
 function _date2array($date)
 {
     $da = array();
     if (is_string($date)) {
         if (preg_match('/^\\d+:\\d+(:\\d+|)(\\s+[ap]m|)$/i', $date)) {
             $date = date('Y-m-d ') . $date;
             $getDate = false;
         } else {
             $getDate = true;
         }
         include_once 'Date.php';
         $dObj = new Date($date);
         if ($getDate) {
             $da['d'] = $dObj->getDay();
             $da['l'] = $da['D'] = $dObj->getDayOfWeek();
             $da['m'] = $da['M'] = $da['F'] = $dObj->getMonth();
             $da['Y'] = $da['y'] = $dObj->getYear();
         }
         $da['H'] = $dObj->getHour();
         $da['h'] = $da['H'] % 12;
         if ($da['h'] == 0) {
             $da['h'] = 12;
         }
         $da['g'] = $da['h'];
         $da['i'] = $dObj->getMinute();
         $da['s'] = $dObj->getSecond();
         if ($da['H'] >= 12) {
             $da['a'] = 'pm';
             $da['A'] = 'PM';
         } else {
             $da['a'] = 'am';
             $da['A'] = 'AM';
         }
         unset($dObj);
     } else {
         if (is_int($date)) {
             $time = $date;
         } else {
             $time = time();
         }
         $da['d'] = date('d', $time);
         $da['l'] = $da['D'] = date('w', $time);
         $da['m'] = $da['M'] = $da['F'] = date('m', $time);
         $da['Y'] = $da['y'] = date('Y', $time);
         $da['H'] = date('H', $time);
         $da['g'] = date('g', $time);
         $da['h'] = date('h', $time);
         $da['i'] = date('i', $time);
         $da['s'] = date('s', $time);
         $da['a'] = date('a', $time);
         $da['A'] = date('A', $time);
     }
     DB_DataObject_FormBuilder::debug('<i>_date2array():</i> from ' . $date . ' to ' . serialize($da) . ' ...');
     return $da;
 }
开发者ID:laiello,项目名称:ya-playsms,代码行数:71,代码来源:FormBuilder.php

示例9: Date

 /**
  * Build the internal arrays that contain data about the calculated holidays
  *
  * @access protected
  * @return boolean true on success, otherwise a PEAR_ErrorStack object
  * @throws object PEAR_ErrorStack
  */
 function _buildHolidays()
 {
     /**
      * New Year's Day
      */
     $newYearsDay = new Date($this->_year . '-01-01');
     if ($newYearsDay->getDayOfWeek() == 0) {
         $this->_addHoliday('newYearsDay', $this->_year . '-01-02', 'Substitute Bank Holiday in lieu of New Year\'s Day');
     } elseif ($newYearsDay->getDayOfWeek() == 6) {
         $this->_addHoliday('newYearsDay', $this->_year . '-01-03', 'Substitute Bank Holiday in lieu of New Year\'s Day');
     } else {
         $this->_addHoliday('newYearsDay', $newYearsDay, 'New Year\'s Day');
     }
     /**
      * Easter Sunday
      */
     $easterDate = Date_Holidays_Driver_Christian::calcEaster($this->_year);
     /**
      * Good Friday
      */
     $goodFridayDate = new Date($easterDate);
     $goodFridayDate = $this->_addDays($easterDate, -2);
     $this->_addHoliday('goodFriday', $goodFridayDate, 'Good Friday');
     /**
      * Easter Monday
      */
     $this->_addHoliday('easterMonday', $easterDate->getNextDay(), 'Easter Monday');
     /**
      * May Day Bank Holiday
      */
     $earlyMayDate = Date_Holidays_Driver_USA::_calcNthMondayInMonth(5, 1);
     $this->_addHoliday('mayDay', $earlyMayDate, 'May Day Bank Holiday');
     /**
      * Spring Bank Holiday
      */
     $springBankDate = Date_Holidays_Driver_USA::_calcLastMondayInMonth(5);
     $this->_addHoliday('springBank', $springBankDate, 'Spring Bank Holiday');
     /**
      * Summer Bank Holiday
      */
     $summerBankDate = Date_Holidays_Driver_USA::_calcLastMondayInMonth(8);
     $this->_addHoliday('summerBank', $summerBankDate, 'Summer Bank Holiday');
     /**
      * Christmas and Boxing Day
      */
     $christmasDay = new Date($this->_year . '-12-25');
     if ($christmasDay->getDayOfWeek() == 0) {
         $this->_addHoliday('boxingDay', $this->_year . '-12-26', 'Boxing Day');
         $this->_addHoliday('christmasDay', $this->_year . '-12-27', 'Substitute Bank Holiday in lieu of Christmas Day');
     } elseif ($christmasDay->getDayOfWeek() == 5) {
         $this->_addHoliday('christmasDay', $christmasDay, 'Christmas Day');
         $this->_addHoliday('boxingDay', $this->_year . '-12-28', 'Substitute Bank Holiday in lieu of Boxing Day');
     } elseif ($christmasDay->getDayOfWeek() == 6) {
         $this->_addHoliday('christmasDay', $this->_year . '-12-28', 'Substitute Bank Holiday in lieu of Christmas Day');
         $this->_addHoliday('boxingDay', $this->_year . '-12-27', 'Substitute Bank Holiday in lieu of Boxing Day');
     } else {
         $this->_addHoliday('christmasDay', $christmasDay, 'Christmas Day');
         $this->_addHoliday('boxingDay', $this->_year . '-12-26', 'Boxing Day');
     }
     if (Date_Holidays::errorsOccurred()) {
         return Date_Holidays::getErrorStack();
     }
     return true;
 }
开发者ID:Raithlin,项目名称:web2project-holiday,代码行数:71,代码来源:EnglandWales.php

示例10: sprintf

 /**
  * Calculate nearest workday for a certain day
  *
  * @access   private
  * @param    int $month  month
  * @param    int $day    day
  * @return   object Date date
  */
 function _calcNearestWorkDay($month, $day)
 {
     $month = sprintf("%02d", $month);
     $day = sprintf("%02d", $day);
     $date = new Date($this->_year . '-' . $month . '-' . $day);
     // When one of these holidays falls on a Saturday, the previous day is also a holiday
     // When New Year's Day, Independence Day, or Christmas Day falls on a Sunday, the next day is also a holiday.
     if ($date->getDayOfWeek() == 0) {
         // bump it up one
         $date = $date->getNextDay();
     }
     if ($date->getDayOfWeek() == 6) {
         // push it back one
         $date = $date->getPrevDay();
     }
     return $date;
 }
开发者ID:slawekmikula,项目名称:dotproject,代码行数:25,代码来源:USA.php

示例11: sprintf

 /**
  * Calculate nearest workday for a certain day
  *
  * @param int $month month
  * @param int $day   day
  *
  * @access   private
  * @return   object Date date
  */
 function _calcNearestWorkDay($month, $day)
 {
     $month = sprintf("%02d", $month);
     $day = sprintf("%02d", $day);
     $date = new Date($this->_year . '-' . $month . '-' . $day);
     // When a public holiday falls on a
     // Sunday, the next day is also a holiday.
     if ($date->getDayOfWeek() == 0) {
         // bump it up one
         $date = $date->getNextDay();
     }
     return $date;
 }
开发者ID:Raithlin,项目名称:web2project-holiday,代码行数:22,代码来源:SouthAfrica.php

示例12: Date


//.........这里部分代码省略.........
     $corpusChristiDate = new Date($whitsunDate);
     $corpusChristiDate->addSpan(new Date_Span('11, 0, 0, 0'));
     $this->_addHoliday('corpusChristi', $corpusChristiDate, 'Feast of Corpus Christi');
     /**
      * Heart of Jesus 
      *
      * Friday of the 3rd week past Whitsun
      */
     $heartJesusDate = new Date($whitsunDate);
     $heartJesusDate->addSpan(new Date_Span('19, 0, 0, 0'));
     $this->_addHoliday('heartJesus', $heartJesusDate, 'Heart of Jesus celebration');
     /**
      * Johannis celebration
      */
     $this->_addHoliday('johannisCelebration', $this->_year . '-06-24', 'Johannis celebration');
     /**
      * Petrus and Paulus
      */
     $this->_addHoliday('petrusAndPaulus', $this->_year . '-06-29', 'Petrus and Paulus');
     /**
      * Ascension of Maria
      */
     $this->_addHoliday('mariaAscension', $this->_year . '-08-15', 'Ascension of Maria');
     /**
      * Celebration of raising the Cross
      */
     $this->_addHoliday('crossRaising', $this->_year . '-09-14', 'Celebration of raising the Cross');
     /**
      * Thanks Giving
      * 
      * Sunday past Michaelis (29. September)
      */
     $michaelisDate = new Date($this->_year . '-09-29');
     $dayOfWeek = $michaelisDate->getDayOfWeek();
     $michaelisDate->addSpan(new Date_Span(sprintf('%d, 0, 0, 0', 7 - $dayOfWeek)));
     $thanksGivingDate = $michaelisDate;
     $this->_addHoliday('thanksGiving', $thanksGivingDate, 'Thanks Giving');
     /**
      * Kermis
      *
      * 3rd Sunday in October
      */
     $kermisDate = new Date($this->_year . '-10-01');
     $dayOfWeek = $kermisDate->getDayOfWeek();
     if ($dayOfWeek != 0) {
         $kermisDate->addSpan(new Date_Span(sprintf('%d, 0, 0, 0', 7 - $dayOfWeek)));
     }
     $kermisDate->addSpan(new Date_Span('14, 0, 0, 0'));
     $this->_addHoliday('kermis', $kermisDate, 'Kermis');
     /**
      * Reformation Day
      */
     $this->_addHoliday('reformationDay', $this->_year . '-10-31', 'Reformation Day');
     /**
      * All Saints' Day
      */
     $this->_addHoliday('allSaintsDay', $this->_year . '-11-01', 'All Saints\' Day');
     /**
      * All Souls' Day
      */
     $this->_addHoliday('allSoulsDay', $this->_year . '-11-02', 'All Souls\' Day');
     /**
      * Martin's Day
      */
     $this->_addHoliday('martinsDay', $this->_year . '-11-11', 'Martin\'s Day');
     /**
开发者ID:slawekmikula,项目名称:dotproject,代码行数:67,代码来源:Christian.php

示例13: Date

 /**
  * Build the internal arrays that contain data about the calculated holidays
  *
  * @access   protected
  * @return   boolean true on success, otherwise a PEAR_ErrorStack object
  * @throws   object PEAR_ErrorStack
  */
 function _buildHolidays()
 {
     $easterDate = Date_Holidays_Driver_Iceland::calcEaster($this->_year);
     /**
      * New Year's Day
      */
     $this->_addHoliday('newYearsDay', $this->_year . '-01-01', 'New Year\'s Day');
     $this->_addTranslationForHoliday('newYearsDay', 'is_IS', 'Nýársdagur');
     /**
      * Epiphany
      */
     $this->_addHoliday('epiphany', $this->_year . '-01-06', 'Epiphany');
     $this->_addTranslationForHoliday('epiphany', 'is_IS', 'Þrettándinn');
     /**
      * Husband's Day
      * From http://www.isholf.is/gullis/jo/feasts_and_celebrations.htm
      * Þorri is one of the old Icelandic months. It always begins on
      * a Friday, between the 19th and the 25th of January, and ends on
      * a Saturday between the 18th and 24th of February. The first day
      * of Þorri is called Bóndadagur or "Husband's Day/Farmer's Day"
      */
     $hdate = new Date($this->_year . "-01-19");
     while ($hdate->getDayOfWeek() != 5) {
         $hdate = $hdate->getNextDay();
     }
     $this->_addHoliday('husbandsDay', $hdate, 'Husband\'s Day');
     $this->_addTranslationForHoliday('husbandsDay', 'is_IS', 'Bóndadagur');
     /**
      * Woman's Day
      * Calculate Sunday in the 18th week of winter, ie between Feb 18-24.
      */
     $wdate = new Date($this->_year . "-02-18");
     while ($wdate->getDayOfWeek() != 0) {
         $wdate = $wdate->getNextDay();
     }
     $this->_addHoliday('womansDay', $wdate, 'Woman\'s Day');
     $this->_addTranslationForHoliday('womansDay', 'is_IS', 'Konudagur');
     $shroveMondayDate = $this->_addDays($easterDate, -41);
     $this->_addHoliday('shroveMonday', $shroveMondayDate, 'Shrove Monday');
     $this->_addTranslationForHoliday('shroveMonday', 'is_IS', 'Bolludagur');
     $shroveTuesdayDate = $this->_addDays($easterDate, -40);
     $this->_addHoliday('shroveTuesday', $shroveTuesdayDate, 'Shrove Tuesday');
     $this->_addTranslationForHoliday('shroveTuesday', 'is_IS', 'Sprengidagur');
     $ashWednesdayDate = $this->_addDays($easterDate, -39);
     $this->_addHoliday('ashWednesday', $ashWednesdayDate, 'Ash Wednesday');
     $this->_addTranslationForHoliday('ashWednesday', 'is_IS', 'Öskudagur');
     /**
      * Palm Sunday
      */
     $palmSundayDate = $this->_addDays($easterDate, -7);
     $this->_addHoliday('palmSunday', $palmSundayDate, 'Palm Sunday');
     $this->_addTranslationForHoliday('palmSunday', 'is_IS', 'Pálmasunnudagur');
     /**
      * Maundy Thursday
      */
     $maundyThursdayDate = $this->_addDays($easterDate, -3);
     $this->_addHoliday('maundyThursday', $maundyThursdayDate, 'Maundy Thursday');
     $this->_addTranslationForHoliday('maundyThursday', 'is_IS', 'Skírdagur');
     /**
      * Good Friday / Black Friday
      */
     $goodFridayDate = $this->_addDays($easterDate, -2);
     $this->_addHoliday('goodFriday', $goodFridayDate, 'Good Friday');
     $this->_addTranslationForHoliday('goodFriday', 'is_IS', 'Föstudaginn langi');
     /**
      * Easter Day
      */
     $this->_addHoliday('easter', $easterDate, 'Easter Day');
     $this->_addTranslationForHoliday('easter', 'is_IS', 'Páskadagur');
     /**
      * Easter Monday
      */
     $this->_addHoliday('easterMonday', $easterDate->getNextDay(), 'Easter Monday');
     $this->_addTranslationForHoliday('easterMonday', 'is_IS', 'Annar í páskum');
     /**
      * First Day of Summer
      * First Thursday after 18 April
      */
     $juneDate = new Date($this->_year . '-04-18');
     $dayOfWeek = $juneDate->getDayOfWeek();
     $midSummerDate = $this->_addDays($juneDate, 4 - $dayOfWeek);
     $this->_addHoliday('firstDayOfSummer', $midSummerDate, 'First Day of Summer');
     $this->_addTranslationForHoliday('firstDayOfSummer', 'is_IS', 'Sumardagurinn fyrsti');
     $mayDay = new Date($this->_year . '-05-01');
     $this->_addHoliday('mayDay', $mayDay, 'May Day');
     $this->_addTranslationForHoliday('mayDay', 'is_IS', 'Verkalýðsdagurinn');
     $mothersDay = new Date($this->_year . '-05-13');
     $this->_addHoliday('mothersDay', $mothersDay, 'Mothers\' Day');
     $this->_addTranslationForHoliday('mothersDay', 'is_IS', 'Mæðradagurinn');
     $whitsunDate = $this->_addDays($easterDate, 49);
     $this->_addHoliday('whitsun', $whitsunDate, 'White Sunday');
     $this->_addTranslationForHoliday('whitsun', 'is_IS', 'Hvítasunnudagur');
     /**
//.........这里部分代码省略.........
开发者ID:Raithlin,项目名称:web2project-holiday,代码行数:101,代码来源:Iceland.php

示例14: convertDateToOperationIntervalID

 /**
  * A method to convert a Date object into the appropriate operation
  * interval ID (of the week).
  *
  * Works by finding out how many days, hours, minutes into the week the time is, and
  * then converting that into how many minutes into the week the time is. This value
  * is then divided by the interval length (in minutes) to determine how many intervals
  * into the week the time is.
  *
  * @static
  * @param Date $oDate The date to convert.
  * @param integer $operation_interval Optional length of the operation interval
  *                                    in minutes. If not given, will use the
  *                                    currently defined operation interval.
  * @return integer The operation interval ID that the time is in.
  */
 function convertDateToOperationIntervalID($oDate, $operationInterval = 0)
 {
     if ($operationInterval < 1) {
         $operationInterval = OX_OperationInterval::getOperationInterval();
     }
     // Convert to UTC
     $oDateCopy = new Date($oDate);
     $oDateCopy->toUTC();
     $days = $oDateCopy->getDayOfWeek();
     $hours = $oDateCopy->getHour();
     $minutes = $oDateCopy->getMinute();
     $totalMinutes = $days * 24 * 60 + $hours * 60 + $minutes;
     return (int) floor($totalMinutes / $operationInterval);
 }
开发者ID:villos,项目名称:tree_admin,代码行数:30,代码来源:OperationInterval.php

示例15: Date

 /**
  * Build the internal arrays that contain data about the calculated holidays
  *
  * @access   protected
  * @return   boolean true on success, otherwise a PEAR_ErrorStack object
  * @throws   object PEAR_ErrorStack
  */
 function _buildHolidays()
 {
     /**
      * New Year's Day
      */
     $this->_addHoliday('newYearsDay', $this->_year . '-01-01', 'New Year\'s Day');
     $this->_addTranslationForHoliday('newYearsDay', 'ga_IE', 'Lá na Caille');
     /**
      * Epiphany
      */
     $this->_addHoliday('epiphany', $this->_year . '-01-06', 'Epiphany');
     $this->_addTranslationForHoliday('epiphany', 'ga_IE', 'Nollag na mBan');
     /**
      * St Patrick's Day.
      */
     $this->_addHoliday('stPatricksDay', $this->_year . '-03-17', 'Saint Patrick\'s Day');
     $this->_addTranslationForHoliday('stPatricksDay', 'ga_IE', 'Lá Fhéile Pádraig');
     /**
      * Easter Sunday
      */
     $easterDate = Date_Holidays_Driver_Ireland::calcEaster($this->_year);
     $this->_addHoliday('easter', $easterDate, 'Easter Sunday');
     $this->_addTranslationForHoliday('easter', 'ga_IE', 'Domhnach Cásca');
     /**
      * Good Friday / Black Friday
      */
     $goodFridayDate = $this->_addDays($easterDate, -2);
     $this->_addHoliday('goodFriday', $goodFridayDate, 'Good Friday');
     $this->_addTranslationForHoliday('goodFriday', 'ga_IE', 'Aoine Cásca');
     /**
      * Easter Monday
      */
     $this->_addHoliday('easterMonday', $easterDate->getNextDay(), 'Easter Monday');
     $this->_addTranslationForHoliday('easterMonday', 'ga_IE', 'Luan Cásca');
     /**
      * May Bank Holiday
      */
     $dn = $this->_calcFirstMonday('05');
     $this->_addHoliday('mayDayBankHoliday', $dn, 'May Bank Holiday');
     $this->_addTranslationForHoliday('mayDayBankHoliday', 'ga_IE', 'Lá Bealtaine');
     /**
      * Pentecost (determines Whit Monday, Ascension Day and
      * Feast of Corpus Christi)
      */
     $pentecostDate = $this->_addDays($easterDate, 49);
     $this->_addHoliday('pentecost', $pentecostDate, 'Pentecost');
     $this->_addTranslationForHoliday('pentecost', 'ga_IE', 'An Chincís');
     /**
      * Ascension Day
      */
     $ascensionDayDate = $this->_addDays($pentecostDate, -10);
     $this->_addHoliday('ascensionDay', $ascensionDayDate, 'Ascension Day');
     $this->_addTranslationForHoliday('ascensionDay', 'ga_IE', 'Deascabhála');
     /**
      * June Bank Holiday
      */
     $dn = $this->_calcFirstMonday('06');
     $this->_addHoliday('juneBankHoliday', $dn, 'June Bank Holiday');
     $this->_addTranslationForHoliday('juneBankHoliday', 'ga_IE', 'Lá Meitheamh');
     /**
      * Midsummer
      * Saturday past 20th, June
      */
     $juneDate = new Date($this->_year . '-06-20');
     $dayOfWeek = $juneDate->getDayOfWeek();
     $midSummerDate = $this->_addDays($juneDate, 6 - $dayOfWeek);
     $this->_addHoliday('midSummer', $midSummerDate, 'Midsummer Day');
     $this->_addTranslationForHoliday('midSummer', 'ga_IE', 'Lá Fhéile Eoin');
     /**
      * August Bank Holiday
      */
     $dn = $this->_calcFirstMonday('08');
     $this->_addHoliday('augustBankHoliday', $dn, 'August Bank Holiday');
     $this->_addTranslationForHoliday('augustBankHoliday', 'ga_IE', 'Lá Lúnasa');
     /**
      * October Bank Holiday
      */
     $dn = $this->_calcLastMonday('10');
     $this->_addHoliday('octoberBankHoliday', $dn, 'October Bank Holiday');
     $this->_addTranslationForHoliday('octoberBankHoliday', 'ga_IE', 'Lá Samhna');
     /**
      * Christmas Eve
      */
     $this->_addHoliday('christmasEve', $this->_year . '-12-24', 'Christmas Eve');
     $this->_addTranslationForHoliday('christmasEve', 'ga_IE', 'Oíche Nollag');
     /**
      * Christmas day
      */
     $this->_addHoliday('christmasDay', $this->_year . '-12-25', 'Christmas Day');
     $this->_addTranslationForHoliday('christmasDay', 'ga_IE', 'Lá Nollag');
     /**
      * St. Stephen's Day
      */
//.........这里部分代码省略.........
开发者ID:Raithlin,项目名称:web2project-holiday,代码行数:101,代码来源:Ireland.php


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