本文整理汇总了PHP中Date_Calc::nWeekdayOfMonth方法的典型用法代码示例。如果您正苦于以下问题:PHP Date_Calc::nWeekdayOfMonth方法的具体用法?PHP Date_Calc::nWeekdayOfMonth怎么用?PHP Date_Calc::nWeekdayOfMonth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Date_Calc
的用法示例。
在下文中一共展示了Date_Calc::nWeekdayOfMonth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _buildHolidays
//.........这里部分代码省略.........
* differs from Australia in that there is no working day lost if Anzac Day falls on a weekend
*/
$anzacDay = new Date($this->_year . '-04-25');
$this->_addHoliday('anzacDay', $anzacDay, 'Anzac Day');
/**
* The Queen's Birthday.
* always observed on 1st Monday in June
*/
$queensBirthday = Date_Calc::NWeekdayOfMonth(1, 1, 6, $this->_year);
$this->_addHoliday('queensBirthday', $queensBirthday, "Queen\\'s Birthday");
/**
* Labour Day.
* observed as 4th Monday in October
*/
$labourDay = Date_Calc::NWeekdayOfMonth(4, 1, 10, $this->_year);
$this->_addHoliday('labourDay', $labourDay, "Labour Day");
/**
* Christmas and Boxing days
* always observed on a working day (1..5)
* always show Christmas and Boxing days
*/
$christmasDay = new Date($this->_year . '-12-25');
$boxingDay = new Date($this->_year . '-12-26');
$this->_addHoliday('christmasDay', $christmasDay, 'Christmas Day');
$this->_addHoliday('boxingDay', $boxingDay, 'Boxing Day');
if ($christmasDay->getDayOfWeek() == 0) {
$this->_addHoliday('christmasDayHoliday', $this->_year . '-12-27', 'Christmas Day Holiday');
} elseif ($christmasDay->getDayOfWeek() == 5) {
$this->_addHoliday('boxingDayHoliday', $this->_year . '-12-28', 'Boxing Day Holiday');
} elseif ($christmasDay->getDayOfWeek() == 6) {
$this->_addHoliday('christmasDayHoliday', $this->_year . '-12-27', 'Christmas Day Holiday');
$this->_addHoliday('boxingDayHoliday', $this->_year . '-12-28', 'Boxing Day Holiday');
}
/**
* Regional anniversary calculations
* http://www.dol.govt.nz/er/holidaysandleave/publicholidays/publicholidaydates/current.asp
* ordered by date of observation
* Note - where rule may be modified by proximity of Easter, this is NOT taken into account
*
* Each of 8 regions can use common rule of nearest Monday
* Southland 17 Jan
* Wellington 22 Jan
* Auckland 29 Jan
* Nelson 1 Feb
* Otago 23 Mar (some local variation)
* Marlborough 1 Nov
* Chatam Islands 30 Nov
* Westland 1 Dec (some local variation)
*/
$anniversaryDaySd = new Date($this->_year . '-01-17');
$this->_addHoliday('anniversaryDaySd', Date_Holidays_Driver_NewZealand::nearestMonday($anniversaryDaySd), "Southland Anniversary Day");
$anniversaryDayWn = new Date($this->_year . '-01-22');
$this->_addHoliday('anniversaryDayWn', Date_Holidays_Driver_NewZealand::nearestMonday($anniversaryDayWn), "Wellington Anniversary Day");
$anniversaryDayAk = new Date($this->_year . '-01-29');
$this->_addHoliday('anniversaryDayAk', Date_Holidays_Driver_NewZealand::nearestMonday($anniversaryDayAk), "Auckland Anniversary Day");
$anniversaryDayNn = new Date($this->_year . '-02-01');
$this->_addHoliday('anniversaryDayNn', Date_Holidays_Driver_NewZealand::nearestMonday($anniversaryDayNn), "Nelson Anniversary Day");
$anniversaryDayOo = new Date($this->_year . '-03-23');
$this->_addHoliday('anniversaryDayOo', Date_Holidays_Driver_NewZealand::nearestMonday($anniversaryDayOo), "Otago Anniversary Day");
$anniversaryDayMb = new Date($this->_year . '-11-01');
$this->_addHoliday('anniversaryDayMb', Date_Holidays_Driver_NewZealand::nearestMonday($anniversaryDayMb), "Marlborough Anniversary Day");
$anniversaryDayCi = new Date($this->_year . '-11-30');
$this->_addHoliday('anniversaryDayCi', Date_Holidays_Driver_NewZealand::nearestMonday($anniversaryDayCi), "Chatam Islands Anniversary Day");
$anniversaryDayWd = new Date($this->_year . '-12-01');
$this->_addHoliday('anniversaryDayWd', Date_Holidays_Driver_NewZealand::nearestMonday($anniversaryDayWd), "Westland Anniversary Day");
/**
* Taranaki Anniversary.
* 2nd Monday in March.
*/
$anniversaryDayTk = Date_Calc::nWeekdayOfMonth(2, 1, 3, $this->_year);
$this->_addHoliday('anniversaryDayTk', $anniversaryDayTk, "Taranaki Anniversary Day");
/**
* South Canterbury Anniversary.
* 4th Monday in September.
*/
$anniversaryDaySc = Date_Calc::nWeekdayOfMonth(4, 1, 9, $this->_year);
$this->_addHoliday('anniversaryDaySc', $anniversaryDaySc, "South Canterbury Anniversary Day");
/**
* Hawkes' Bay Anniversary.
* Friday before Labour Day (or 3rd Friday in October).
*
*/
$anniversaryDayHb = Date_Calc::nWeekdayOfMonth(3, 5, 10, $this->_year);
$this->_addHoliday('anniversaryDayHb', $anniversaryDayHb, "Hawkes\\' Bay Anniversary");
/**
* Canterbury Anniversary or Show Day for North and Central Canterbury.
* 2nd Friday after 1st Tuesday in month of November.
* find 1st Tuesday then add 10 days
*/
$anniversaryDayNc = $this->_calcNthWeekDayInMonth(1, 2, 11);
$anniversaryDayNc = $this->_addDays($anniversaryDayNc, 10);
$this->_addHoliday('anniversaryDayNc', $anniversaryDayNc, "Canterbury Anniversary Day");
/**
* Check for errors, and return.
*/
if (Date_Holidays::errorsOccurred()) {
return Date_Holidays::getErrorStack();
}
return true;
}
示例2: _buildHolidays
/**
* Build the internal arrays that contain data about holidays.
*
* @access protected
* @return boolean true on success, otherwise a PEAR_ErrorStack object
* @throws object PEAR_ErrorStack
*/
function _buildHolidays()
{
parent::_buildHolidays();
/*
* Labour Day.
*/
$labourDay = Date_Calc::nWeekdayOfMonth(1, 1, 3, $this->_year);
$this->_addHoliday('labourDay', $labourDay, "Labour Day");
/*
* Foundation Day (Queen's Birthday in other states).
* See http://en.wikipedia.org/wiki/Queen%27s_Official_Birthday#Australia
*/
$foundationDay = Date_Calc::nWeekdayOfMonth(1, 1, 6, $this->_year);
$this->_addHoliday('foundationDay', $foundationDay, "Foundation Day");
/*
* The Queen's Birthday. There is no firm rule to determine this date before
* it is proclaimed, but it is usually the last Monday of September or the
* first Monday of October, to fit in with school terms and the Perth Royal
* Show. Here we assume that whichever of the two is closest to the start of
* Octber will be the holiday; this has been verified to be correct up to and
* including 2013, but dates beyond then should be verified once they've been
* proclaimed (and something added here to account for historical and future
* irregularities).
*/
$y = $this->_year;
$lastMonSept = new Date(Date_Calc::nWeekdayOfMonth('last', 1, 9, $y));
$firstMonOct = new Date(Date_Calc::nWeekdayOfMonth(1, 1, 10, $y));
$daysToEnd = 30 - $lastMonSept->getDay();
$daysToStart = $firstMonOct->getDay();
if ($daysToEnd < $daysToStart) {
$queensBirthday = $lastMonSept;
} else {
$queensBirthday = $firstMonOct;
}
$this->_addHoliday('queensBirthday', $queensBirthday, "Queen's Birthday");
}
示例3: _buildHolidays
/**
* Build the internal arrays that contain data about holidays.
*
* @access protected
* @return boolean true on success, otherwise a PEAR_ErrorStack object
* @throws object PEAR_ErrorStack
*/
function _buildHolidays()
{
parent::_buildHolidays();
/*
* New Year's Day
*/
$newYearsDay = new Date($this->_year . '-01-01');
if ($newYearsDay->getDayOfWeek() == 0) {
// 0 = Sunday
$newYearsDay = $this->_year . '-01-02';
} elseif ($newYearsDay->getDayOfWeek() == 6) {
// 6 = Saturday
$newYearsDay = $this->_year . '-01-03';
}
$this->_addHoliday('newYearsDay', $newYearsDay, 'New Year\'s Day');
/*
* Australia Day
*/
$australiaDay = new Date($this->_year . '-01-26');
if ($australiaDay->getDayOfWeek() == 0) {
// 0 = Sunday
$australiaDay = $this->_year . '-01-27';
} elseif ($australiaDay->getDayOfWeek() == 6) {
// 6 = Saturday
$australiaDay = $this->_year . '-01-28';
}
$this->_addHoliday('australiaDay', $australiaDay, 'Australia Day');
/*
* Easter
*/
$easter = Date_Holidays_Driver_Christian::calcEaster($this->_year);
$goodFridayDate = new Date($easter);
$goodFridayDate = $this->_addDays($easter, -2);
$this->_addHoliday('goodFriday', $goodFridayDate, 'Good Friday');
$this->_addHoliday('easterMonday', $easter->getNextDay(), 'Easter Monday');
/*
* Anzac Day
*/
$anzacDay = new Date($this->_year . '-04-25');
$this->_addHoliday('anzacDay', $anzacDay, 'Anzac Day');
if ($anzacDay->getDayOfWeek() == 0) {
// 0 = Sunday
$anzacDayHol = $this->_year . '-04-26';
$this->_addHoliday('anzacDayHoliday', $anzacDayHol, 'Anzac Day Holiday');
} elseif ($anzacDay->getDayOfWeek() == 6) {
// 6 = Saturday
$anzacDayHol = $this->_year . '-04-27';
$this->_addHoliday('anzacDayHoliday', $anzacDayHol, 'Anzac Day Holiday');
}
/*
* The Queen's Birthday.
* See http://en.wikipedia.org/wiki/Queen%27s_Official_Birthday#Australia
*/
$queensBirthday = Date_Calc::nWeekdayOfMonth(1, 1, 6, $this->_year);
$this->_addHoliday('queensBirthday', $queensBirthday, "Queen's Birthday");
/*
* Christmas and Boxing days
*/
$christmasDay = new Date($this->_year . '-12-25');
$boxingDay = new Date($this->_year . '-12-26');
$this->_addHoliday('christmasDay', $christmasDay, 'Christmas Day');
$this->_addHoliday('boxingDay', $boxingDay, 'Boxing Day');
if ($christmasDay->getDayName() == 'Sunday') {
$this->_addHoliday('boxingDayHoliday', $this->_year . '-12-27', 'Boxing Day Holiday');
} elseif ($christmasDay->getDayName() == 'Friday') {
$this->_addHoliday('boxingDayHoliday', $this->_year . '-12-28', 'Boxing Day Holiday');
} elseif ($christmasDay->getDayName() == 'Saturday') {
$this->_addHoliday('christmasDayHoliday', $this->_year . '-12-27', 'Christmas Day Holiday');
$this->_addHoliday('boxingDayHoliday', $this->_year . '-12-28', 'Boxing Day Holiday');
}
/*
* Check for errors, and return.
*/
if (Date_Holidays::errorsOccurred()) {
return Date_Holidays::getErrorStack();
}
return true;
}