本文整理汇总了PHP中Date_Calc类的典型用法代码示例。如果您正苦于以下问题:PHP Date_Calc类的具体用法?PHP Date_Calc怎么用?PHP Date_Calc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Date_Calc类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: compare
/**
* Overloaded compare method
*
* The convertTZ calls are time intensive calls. When a compare call is
* made in a recussive loop the lag can be significant.
*/
function compare($d1, $d2, $convertTZ = false)
{
if ($convertTZ) {
$d1->convertTZ(new Date_TimeZone('UTC'));
$d2->convertTZ(new Date_TimeZone('UTC'));
}
$days1 = Date_Calc::dateToDays($d1->day, $d1->month, $d1->year);
$days2 = Date_Calc::dateToDays($d2->day, $d2->month, $d2->year);
if ($days1 < $days2) {
return -1;
}
if ($days1 > $days2) {
return 1;
}
if ($d1->hour < $d2->hour) {
return -1;
}
if ($d1->hour > $d2->hour) {
return 1;
}
if ($d1->minute < $d2->minute) {
return -1;
}
if ($d1->minute > $d2->minute) {
return 1;
}
if ($d1->second < $d2->second) {
return -1;
}
if ($d1->second > $d2->second) {
return 1;
}
return 0;
}
开发者ID:juliogallardo1326,项目名称:proc,代码行数:40,代码来源:date.class.php
示例2: _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"> </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
示例3: MAX_getDatesByPeriodLimitStart
function MAX_getDatesByPeriodLimitStart($period, $limit, $start)
{
$begin = $limit + $start - 1;
$end = $start;
switch ($period) {
case 'daily':
$dayBegin = new Date();
$dayBegin->subtractSpan(new Date_Span("{$begin}, 0, 0, 0"));
$dayEnd = new Date();
$dayBegin->subtractSpan(new Date_Span("{$end}, 0, 0, 0"));
break;
case 'weekly':
$dayBegin = new Date(Date_Calc::prevDay());
$dayEnd = new Date(Date_Calc::prevDay());
break;
case 'monthly':
$dayBegin = new Date();
$dayBegin->subtractSpan(new Date_Span('6, 0, 0, 0'));
$dayEnd = new Date();
break;
case 'allstats':
default:
$dayBegin = null;
$dayEnd = null;
}
$aDates = array();
$aDates['day_begin'] = is_object($dayBegin) ? $dayBegin->format('%Y-%m-%d') : '';
$aDates['day_end'] = is_object($dayEnd) ? $dayEnd->format('%Y-%m-%d') : '';
return $aDates;
}
开发者ID:Jaree,项目名称:revive-adserver,代码行数:30,代码来源:stats.php
示例4: compare
/**
* Overloaded compare method
*
* The convertTZ calls are time intensive calls. When a compare call is
* made in a recussive loop the lag can be significant.
*/
function compare($d1, $d2, $convertTZ = false)
{
if ($convertTZ) {
$d1->convertTZ(new Date_TimeZone('UTC'));
$d2->convertTZ(new Date_TimeZone('UTC'));
}
$days1 = Date_Calc::dateToDays($d1->day, $d1->month, $d1->year);
$days2 = Date_Calc::dateToDays($d2->day, $d2->month, $d2->year);
$comp_value = 0;
if ($days1 - $days2) {
$comp_value = $days1 - $days2;
} else {
if ($d1->hour - $d2->hour) {
$comp_value = dPsgn($d1->hour - $d2->hour);
} else {
if ($d1->minute - $d2->minute) {
$comp_value = dPsgn($d1->minute - $d2->minute);
} else {
if ($d1->second - $d2->second) {
$comp_value = dPsgn($d1->second - $d2->second);
}
}
}
}
return dPsgn($comp_value);
}
开发者ID:magsilva,项目名称:dotproject,代码行数:32,代码来源:date.class.php
示例5: _render
protected function _render(Horde_Date $day = null)
{
$this->_start = new Horde_Date(Date_Calc::beginOfWeek($day->mday, $day->month, $day->year, '%Y%m%d000000'));
$this->_end = new Horde_Date($this->_start);
$this->_end->hour = 23;
$this->_end->min = $this->_end->sec = 59;
$this->_end->mday += $this->_days - 1;
}
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:8,代码来源:Week.php
示例6: isbatchingmaintenancecurrent
function isbatchingmaintenancecurrent($batching_expiration_date)
{
$bedate = $batching_expiration_date ? new CDate($batching_expiration_date) : null;
$now = new CDate();
if (Date_Calc::compareDates($bedate->day, $bedate->month, $bedate->year, $now->day, $now->month, $now->year) < 0) {
return "No";
} else {
return "Yes";
}
}
开发者ID:srinivasulurao,项目名称:jonel,代码行数:10,代码来源:vw_depts.php
示例7: cal_work_day_conv
function cal_work_day_conv($val)
{
global $locale_char_set;
$wk = Date_Calc::getCalendarWeek(null, null, null, "%a", LOCALE_FIRST_DAY);
$day_name = $wk[($val - LOCALE_FIRST_DAY) % 7];
if ($locale_char_set == "utf-8" && function_exists("utf8_encode")) {
$day_name = utf8_encode($day_name);
}
return htmlentities($day_name, ENT_COMPAT, $locale_char_set);
}
开发者ID:slawekmikula,项目名称:dotproject,代码行数:10,代码来源:ae_dates.php
示例8: cal_work_day_conv
function cal_work_day_conv($val)
{
global $locale_char_set, $AppUI;
setlocale(LC_TIME, 'en');
$wk = Date_Calc::getCalendarWeek(null, null, null, '%a', LOCALE_FIRST_DAY);
setlocale(LC_ALL, $AppUI->user_lang);
$day_name = $AppUI->_($wk[($val - LOCALE_FIRST_DAY) % 7]);
if ($locale_char_set == 'utf-8' && function_exists('utf8_encode')) {
$day_name = utf8_encode($day_name);
}
return htmlspecialchars($day_name, ENT_COMPAT, $locale_char_set);
}
开发者ID:joly,项目名称:web2project,代码行数:12,代码来源:ae_dates.php
示例9: cal_work_day_conv
function cal_work_day_conv($val)
{
global $locale_char_set;
setlocale(LC_ALL, 'en_AU' . ($locale_char_set ? '.' . $locale_char_set : '.utf8'));
$wk = Date_Calc::getCalendarWeek(null, null, null, "%a", LOCALE_FIRST_DAY);
setlocale(LC_ALL, $AppUI->user_lang);
$day_name = $wk[($val - LOCALE_FIRST_DAY) % 7];
if ($locale_char_set == "utf-8" && function_exists("utf8_encode")) {
$day_name = utf8_encode($day_name);
}
return htmlentities($day_name, ENT_COMPAT, $locale_char_set);
}
开发者ID:hoodoogurus,项目名称:dotprojecteap,代码行数:12,代码来源:ae_dates.php
示例10: __construct
/**
*
* @global Horde_Prefs $prefs
* @param Horde_Date $date
*
* @return Kronolith_View_Month
*/
public function __construct(Horde_Date $date)
{
global $prefs;
$this->month = $date->month;
$this->year = $date->year;
// Need to calculate the start and length of the view.
$this->date = new Horde_Date($date);
$this->date->mday = 1;
$this->_startday = $this->date->dayOfWeek();
$this->_daysInView = Date_Calc::weeksInMonth($this->month, $this->year) * 7;
if (!$prefs->getValue('week_start_monday')) {
$this->_startOfView = 1 - $this->_startday;
// We may need to adjust the number of days in the view if
// we're starting weeks on Sunday.
if ($this->_startday == Horde_Date::DATE_SUNDAY) {
$this->_daysInView -= 7;
}
$endday = new Horde_Date(array('mday' => Horde_Date_Utils::daysInMonth($this->month, $this->year), 'month' => $this->month, 'year' => $this->year));
$endday = $endday->dayOfWeek();
if ($endday == Horde_Date::DATE_SUNDAY) {
$this->_daysInView += 7;
}
} else {
if ($this->_startday == Horde_Date::DATE_SUNDAY) {
$this->_startOfView = -5;
} else {
$this->_startOfView = 2 - $this->_startday;
}
}
$startDate = new Horde_Date(array('year' => $this->year, 'month' => $this->month, 'mday' => $this->_startOfView));
$endDate = new Horde_Date(array('year' => $this->year, 'month' => $this->month, 'mday' => $this->_startOfView + $this->_daysInView));
if ($prefs->getValue('show_shared_side_by_side')) {
$allCalendars = Kronolith::listInternalCalendars();
$this->_currentCalendars = array();
foreach ($GLOBALS['calendar_manager']->get(Kronolith::DISPLAY_CALENDARS) as $id) {
$this->_currentCalendars[$id] = $allCalendars[$id];
}
} else {
$this->_currentCalendars = array('internal_0' => true);
}
try {
$this->_events = Kronolith::listEvents($startDate, $endDate);
} catch (Exception $e) {
$GLOBALS['notification']->push($e, 'horde.error');
$this->_events = array();
}
if (!is_array($this->_events)) {
$this->_events = array();
}
}
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:57,代码来源:Month.php
示例11: getAgo
public static function getAgo($timestamp)
{
if ($timestamp === null) {
return '';
}
$diffdays = Date_Calc::dateDiff(date('j', $timestamp), date('n', $timestamp), date('Y', $timestamp), date('j'), date('n'), date('Y'));
/* An error occured. */
if ($diffdays == -1) {
return;
}
$ago = $diffdays * Date_Calc::compareDates(date('j', $timestamp), date('n', $timestamp), date('Y', $timestamp), date('j'), date('n'), date('Y'));
if ($ago < -1) {
return sprintf(Horde_Model_Translation::t(" (%s days ago)"), $diffdays);
} elseif ($ago == -1) {
return Horde_Model_Translation::t(" (yesterday)");
} elseif ($ago == 0) {
return Horde_Model_Translation::t(" (today)");
} elseif ($ago == 1) {
return Horde_Model_Translation::t(" (tomorrow)");
} else {
return sprintf(Horde_Model_Translation::t(" (in %s days)"), $diffdays);
}
}
开发者ID:jubinpatel,项目名称:horde,代码行数:23,代码来源:Date.php
示例12: date
//.........这里部分代码省略.........
if ($day < 1 || $day > 31) {
return false;
}
break;
case 'm':
case 'n':
if ($next == 'm') {
$month = (int) Validate::_substr($date, 0, 2);
} else {
$month = (int) Validate::_substr($date, 1, 2);
}
if ($month < 1 || $month > 12) {
return false;
}
break;
case 'Y':
case 'y':
if ($next == 'Y') {
$year = Validate::_substr($date, 4);
$year = (int) $year ? $year : '';
} else {
$year = (int) (substr(date('Y'), 0, 2) . Validate::_substr($date, 2));
}
if (strlen($year) != 4 || $year < 0 || $year > 9999) {
return false;
}
break;
case 'g':
case 'h':
if ($next == 'g') {
$hour = Validate::_substr($date, 1, 2);
} else {
$hour = Validate::_substr($date, 2);
}
if (!preg_match('/^\\d+$/', $hour) || $hour < 0 || $hour > 12) {
return false;
}
break;
case 'G':
case 'H':
if ($next == 'G') {
$hour = Validate::_substr($date, 1, 2);
} else {
$hour = Validate::_substr($date, 2);
}
if (!preg_match('/^\\d+$/', $hour) || $hour < 0 || $hour > 24) {
return false;
}
break;
case 's':
case 'i':
$t = Validate::_substr($date, 2);
if (!preg_match('/^\\d+$/', $t) || $t < 0 || $t > 59) {
return false;
}
break;
default:
trigger_error("Not supported char `{$next}' after % in offset " . ($i + 2), E_USER_WARNING);
}
$i++;
} else {
//literal
if (Validate::_substr($date, 1) != $c) {
return false;
}
}
}
}
// there is remaing data, we don't want it
if (strlen($date) && strtolower($format) != 'rfc822_compliant') {
return false;
}
if (isset($day) && isset($month) && isset($year)) {
if (!checkdate($month, $day, $year)) {
return false;
}
if (strtolower($format) == 'rfc822_compliant') {
if ($weekday != date("D", mktime(0, 0, 0, $month, $day, $year))) {
return false;
}
}
if ($min) {
include_once 'Date/Calc.php';
if (is_a($min, 'Date') && Date_Calc::compareDates($day, $month, $year, $min->getDay(), $min->getMonth(), $min->getYear()) < 0) {
return false;
} elseif (is_array($min) && Date_Calc::compareDates($day, $month, $year, $min[0], $min[1], $min[2]) < 0) {
return false;
}
}
if ($max) {
include_once 'Date/Calc.php';
if (is_a($max, 'Date') && Date_Calc::compareDates($day, $month, $year, $max->getDay(), $max->getMonth(), $max->getYear()) > 0) {
return false;
} elseif (is_array($max) && Date_Calc::compareDates($day, $month, $year, $max[0], $max[1], $max[2]) > 0) {
return false;
}
}
}
return true;
}
开发者ID:ljarray,项目名称:dbpedia,代码行数:101,代码来源:Validate.php
示例13: getPrevWeekday
/**
* Get a Date object for the weekday before this one
*
* Get a Date object for the weekday before this one.
* The time of the returned Date object is the same as this time.
*
* @access public
* @return object Date Date representing the previous weekday
*/
function getPrevWeekday()
{
$day = Date_Calc::prevWeekday($this->day, $this->month, $this->year, "%Y-%m-%d");
$date = sprintf("%s %02d:%02d:%02d", $day, $this->hour, $this->minute, $this->second);
$newDate = new Date();
$newDate->setDate($date);
return $newDate;
}
开发者ID:mickdane,项目名称:zidisha,代码行数:17,代码来源:Date.php
示例14: showDays
function showDays()
{
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;
$days_difference = $end_date->dateDiff($start_date);
$actual_date = $start_date;
$working_days_count = 0;
$allocated_hours_sum = 0;
$table_header = "<tr><th>" . $AppUI->_("User") . "</th>";
for ($i = 0; $i <= $days_difference; $i++) {
if ($actual_date->isWorkingDay() || !$actual_date->isWorkingDay() && !$hideNonWd) {
$table_header .= "<th>" . utf8_encode(Date_Calc::getWeekdayAbbrname($actual_date->day, $actual_date->month, $actual_date->year, 3)) . "<br>" . $actual_date->format('%d/%m') . "</th>";
}
if ($actual_date->isWorkingDay()) {
$working_days_count++;
}
$actual_date->addDays(1);
}
$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 = $start_date;
for ($i = 0; $i <= $days_difference; $i++) {
if ($actual_date->isWorkingDay() || !$actual_date->isWorkingDay() && !$hideNonWd) {
$table_rows .= "<td>";
if (isset($user_usage[$user_id][$actual_date->format("%Y%m%d")])) {
$hours = number_format($user_usage[$user_id][$actual_date->format("%Y%m%d")], 2);
$table_rows .= $hours;
$percentage_used = round($hours / dPgetConfig("daily_working_hours") * 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}'> </div>";
} else {
$table_rows .= " ";
}
$table_rows .= "</td>";
}
$actual_date->addDays(1);
}
$array_sum = array_sum($user_usage[$user_id]);
$average_user_usage = number_format($array_sum / ($working_days_count * 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}'> </div></td>";
$table_rows .= "</tr>";
}
}
$total_hours_capacity = $working_days_count * dPgetConfig("daily_working_hours") * count($user_usage);
$total_hours_capacity_all = $working_days_count * dPgetConfig("daily_working_hours") * count($user_list);
}
开发者ID:n2i,项目名称:xvnkb,代码行数:61,代码来源:allocateduserhours.php
示例15: getDuration
public function getDuration()
{
if (isset($this->_duration)) {
return $this->_duration;
}
if ($this->start && $this->end) {
$dur_day_match = Date_Calc::dateDiff($this->start->mday, $this->start->month, $this->start->year, $this->end->mday, $this->end->month, $this->end->year);
$dur_hour_match = $this->end->hour - $this->start->hour;
$dur_min_match = $this->end->min - $this->start->min;
while ($dur_min_match < 0) {
$dur_min_match += 60;
--$dur_hour_match;
}
while ($dur_hour_match < 0) {
$dur_hour_match += 24;
--$dur_day_match;
}
} else {
$dur_day_match = 0;
$dur_hour_match = 1;
$dur_min_match = 0;
}
$this->_duration = new stdClass();
$this->_duration->day = $dur_day_match;
$this->_duration->hour = $dur_hour_match;
$this->_duration->min = $dur_min_match;
$this->_duration->wholeDay = $this->isAllDay();
return $this->_duration;
}
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:29,代码来源:Event.php
示例16: EVLIST_smallmonth
/**
* Display a small monthly calendar for the current month.
* Dates that have events scheduled are highlighted.
*
* @param integer $year Year to display, default is current year
* @param integer $month Starting month
* @return string HTML for calendar page
*/
function EVLIST_smallmonth($year = 0, $month = 0, $opts = array())
{
global $_CONF, $_EV_CONF, $LANG_MONTH, $_SYSTEM;
$retval = '';
// Default to the current year
if ($year == 0) {
$year = date('Y');
}
if ($month == 0) {
$month = date('m');
}
$monthnum_str = sprintf("%02d", (int) $month);
// Get all the dates in the period
$starting_date = date('Y-m-d', mktime(0, 0, 0, $month, 1, $year));
$ending_date = date('Y-m-d', mktime(23, 59, 59, $month, 31, $year));
$calendarView = Date_Calc::getCalendarMonth($month, $year, '%Y-%m-%d');
$events = EVLIST_getEvents($starting_date, $ending_date, $opts);
$T = new Template(EVLIST_PI_PATH . '/templates');
$T->set_file(array('smallmonth' => 'phpblock_month.thtml'));
$T->set_var('thisyear', $year);
$T->set_var('month', $month);
$T->set_var('monthname', $LANG_MONTH[(int) $month]);
// Set each day column header to the first letter of the day name
$T->set_block('smallmonth', 'daynames', 'nBlock');
$daynames = EVLIST_getDayNames(1);
foreach ($daynames as $key => $dayname) {
$T->set_var('dayname', $dayname);
$T->parse('nBlock', 'daynames', true);
}
$T->set_block('smallmonth', 'week', 'wBlock');
USES_class_date();
$dt = new Date('now', $_CONF['timezone']);
foreach ($calendarView as $weeknum => $weekdata) {
list($weekYear, $weekMonth, $weekDay) = explode('-', $weekdata[0]);
$T->set_var(array('weekyear' => $weekYear, 'weekmonth' => $weekMonth, 'weekday' => $weekDay));
$T->set_block('smallmonth', 'day', 'dBlock');
foreach ($weekdata as $daynum => $daydata) {
list($y, $m, $d) = explode('-', $daydata);
$T->clear_var('no_day_link');
if ($daydata == $_EV_CONF['_today']) {
$dayclass = 'monthtoday';
} elseif ($m == $monthnum_str) {
$dayclass = 'monthon';
} else {
$T->set_var('no_day_link', 'true');
$dayclass = 'monthoff';
}
$popup = '';
if (isset($events[$daydata])) {
// Create the tooltip hover text
$daylinkclass = $dayclass == 'monthoff' ? 'nolink-events' : 'day-events';
foreach ($events[$daydata] as $event) {
// Show event titles on different lines if more than one
if (!empty($popup)) {
$popup .= EVLIST_tooltip_newline();
}
// Don't show a time for all-day events
if ($event['allday'] == 0 && $event['rp_date_start'] == $event['rp_date_end']) {
$dt->setTimestamp(strtotime($event['rp_date_start'] . ' ' . $event['rp_time_start1']));
// Time is a localized string, not a timestamp, so
// don't adjust for the timezone
$popup .= $dt->format($_CONF['timeonly'], false) . ': ';
}
$popup .= htmlentities($event['title']);
}
$T->set_var('popup', $popup);
} else {
$daylinkclass = 'day-noevents';
$T->clear_var('popup');
}
$T->set_var(array('daylinkclass' => $daylinkclass, 'dayclass' => $dayclass, 'day' => substr($daydata, 8, 2), 'pi_url' => EVLIST_URL));
$T->parse('dBlock', 'day', true);
}
$T->parse('wBlock', 'week', true);
$T->clear_var('dBlock');
}
$T->parse('output', 'smallmonth');
return $T->finish($T->get_var('output'));
}
开发者ID:NewRoute,项目名称:evlist,代码行数:87,代码来源:evlist_functions.inc.php
示例17: getMonthFromFullName
/**
* Returns the numeric month from the month name or an abreviation
*
* Both August and Aug would return 8.
* Month name is case insensitive.
*
* @param string month name
* @return integer month number
*/
function getMonthFromFullName($month)
{
$month = strtolower($month);
$months = Date_Calc::getMonthNames();
while (list($id, $name) = each($months)) {
if (ereg($month, strtolower($name))) {
return $id;
}
}
return 0;
}
开发者ID:stephen-smith,项目名称:openemr,代码行数:20,代码来源:Calc.php
示例18: roundSeconds
/**
* Rounds seconds up or down to the nearest specified unit
*
* @param int $pn_precision number of digits after the decimal point
* @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 roundSeconds($pn_precision, $pn_day, $pn_month, $pn_year, $pn_hour, $pn_minute, $pn_second, $pb_countleap = DATE_COUNT_LEAP_SECONDS)
{
return Date_Calc::round(DATE_PRECISION_SECOND + $pn_precision, $pn_day, $pn_month, $pn_year, $pn_hour, $pn_minute, $pn_second);
}
开发者ID:222elm,项目名称:dotprojectFrame,代码行数:22,代码来源:Calc.php
示例19: getDayOfWeek
/**
* Returns the number of the day of the week (0=sunday, 1=monday...)
* @param int year (2003)
* @param int month (9)
* @param int day (4)
* @return int weekday number
* @access protected
*/
function getDayOfWeek($y, $m, $d)
{
return Date_Calc::dayOfWeek($d, $m, $y);
}
开发者ID:BackupTheBerlios,项目名称:phpalmanac-svn,代码行数:12,代码来源:PearDate.php
示例20: saveSummary
/**
* A method to update the summary table from the intermediate tables.
*
* @param PEAR::Date $oStartDate The start date/time to update from.
* @param PEAR::Date $oEndDate The end date/time to update to.
* @param array $aActions An array of data types to summarise. Contains
* two array, the first containing the data types,
* and the second containing the connection type
* values associated with those data types, if
* appropriate. For example:
* array(
* 'types' => array(
* 0 => 'request',
* 1 => 'impression',
* 2 => 'click'
* ),
* 'connections' => array(
* 1 => MAX_CONNECTION_AD_IMPRESSION,
* 2 => MAX_CONNECTION_AD_CLICK
* )
* )
* Note that the order of the items must match
* the order of the items in the database tables
* (e.g. in data_intermediate_ad and
* data_summary_ad_hourly for the above example).
* @param string $fromTable The name of the intermediate table to summarise
* from (e.g. 'data_intermediate_ad').
* @param string $toTable The name of the summary table to summarise to
* (e.g. 'data_summary_ad_hourly').
*/
function saveSummary($oStartDate, $oEndDate, $aActions, $fromTable, $toTable)
{
$aConf = $GLOBALS['_MAX']['CONF'];
// Check that there are types to summarise
if (empty($aActions['types']) || empty($aActions['connections'])) {
return;
}
// How many days does the start/end period span?
$days = Date_Calc::dateDiff($oStartDate->getDay(), $oStartDate->getMonth(), $oStartDate->getYear(), $oEndDate->getDay(), $oEndDate->getMonth(), $oEndDate->getYear());
if ($days == 0) {
// Save the data
$this->_saveSummary($oStartDate, $oEndDate, $aActions, $fromTable, $toTable);
} else {
// Save each day's data separately
for ($counter = 0; $counter <= $days; $counter++) {
if ($counter == 0) {
// This is the first day
$oInternalStartDate = new Date();
$oInternalStartDate->copy($oStartDate);
$oInternalEndDate = new Date($oStartDate->format('%Y-%m-%d') . ' 23:59:59');
} elseif ($counter == $days) {
// This is the last day
$oInternalStartDate = new Date($oEndDate->format('%Y-%m-%d') . ' 00:00:00');
$oInternalEndDate = new Date();
$oInternalEndDate->copy($oEndDate);
} else {
// This is a day in the middle
$oDayDate = new Date();
$oDayDate->copy($oStartDate);
$oDayDate->addSeconds(SECONDS_PER_DAY * $counter);
$oInternalStartDate = new Date($oDayDate->format('%Y-%m-%d') . ' 00:00:00');
$oInternalEndDate = new Date($oDayDate->format('%Y-%m-%d') . ' 23:59:59');
}
$this->_saveSummary($oInternalStartDate, $oInternalEndDate, $aActions, $fromTable, $toTable);
}
}
}
开发者ID:villos,项目名称:tree_admin,代码行数:67,代码来源:Statistics.php
注:本文中的Date_Calc类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论