本文整理汇总了PHP中Date_Calc::endOfMonthBySpan方法的典型用法代码示例。如果您正苦于以下问题:PHP Date_Calc::endOfMonthBySpan方法的具体用法?PHP Date_Calc::endOfMonthBySpan怎么用?PHP Date_Calc::endOfMonthBySpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Date_Calc
的用法示例。
在下文中一共展示了Date_Calc::endOfMonthBySpan方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: expandPlannedTransactions
/**
* Expands the planned transactions.
*
* All occurences of planned transactions between now and the targetFutureCalcDate will be inserted
* in finishedTransactions. For distinction the planned transactions will have a 'p' as first character
* in their id.
*
* @throws BadgerException If an illegal repeat unit is used.
*/
public function expandPlannedTransactions()
{
$now = new Date();
$now->setHour(0);
$now->setMinute(0);
$now->setSecond(0);
foreach ($this->plannedTransactions as $currentTransaction) {
$date = new Date($currentTransaction->getBeginDate());
$dayOfMonth = $date->getDay();
//While we have not reached targetFutureCalcDate
while ($this->targetFutureCalcDate->after($date) && !$date->after(is_null($tmp = $currentTransaction->getEndDate()) ? new Date('9999-12-31') : $tmp)) {
$inRange = true;
//Check if there is one or more valutaDate filter and apply them
foreach ($this->filter as $currentFilter) {
if ($currentFilter['key'] == 'valutaDate') {
switch ($currentFilter['op']) {
case 'eq':
if (Date::compare($date, $currentFilter['val']) != 0) {
$inRange = false;
}
break;
case 'lt':
if (Date::compare($date, $currentFilter['val']) >= 0) {
$inRange = false;
}
break;
case 'le':
if (Date::compare($date, $currentFilter['val']) > 0) {
$inRange = false;
}
break;
case 'gt':
if (Date::compare($date, $currentFilter['val']) <= 0) {
$inRange = false;
}
break;
case 'ge':
if (Date::compare($date, $currentFilter['val']) < 0) {
$inRange = false;
}
break;
case 'ne':
if (Date::compare($date, $currentFilter['val']) == 0) {
$inRange = false;
}
break;
case 'bw':
case 'ew':
case 'ct':
if (strncasecmp($date->getFormatted(), $currentFilter['val']->getFormatted(), 9999) != 0) {
$inRange = false;
}
break;
}
if (!$inRange) {
break;
}
}
}
if (!$date->before($now) && $inRange) {
$this->finishedTransactions[] = new FinishedTransaction($this->badgerDb, $this, 'p' . $currentTransaction->getId() . '_' . $date->getDate(), $currentTransaction->getTitle(), $currentTransaction->getAmount(), $currentTransaction->getDescription(), new Date($date), $currentTransaction->getTransactionPartner(), $currentTransaction->getCategory(), $currentTransaction->getOutsideCapital(), false, true, $currentTransaction, 'PlannedTransaction');
}
//do the date calculation
switch ($currentTransaction->getRepeatUnit()) {
case 'day':
$date->addSeconds($currentTransaction->getRepeatFrequency() * 24 * 60 * 60);
break;
case 'week':
$date->addSeconds($currentTransaction->getRepeatFrequency() * 7 * 24 * 60 * 60);
break;
case 'month':
//Set the month
$date = new Date(Date_Calc::endOfMonthBySpan($currentTransaction->getRepeatFrequency(), $date->getMonth(), $date->getYear(), '%Y-%m-%d'));
//And count back as far as the last valid day of this month
while ($date->getDay() > $dayOfMonth) {
$date->subtractSeconds(24 * 60 * 60);
}
break;
case 'year':
$newYear = $date->getYear() + $currentTransaction->getRepeatFrequency();
if ($dayOfMonth == 29 && $date->getMonth() == 2 && !Date_Calc::isLeapYear($newYear)) {
$date->setDay(28);
} else {
$date->setDay($dayOfMonth);
}
$date->setYear($newYear);
break;
default:
throw new BadgerException('Account', 'IllegalRepeatUnit', $currentTransaction->getRepeatUnit());
exit;
}
//.........这里部分代码省略.........
示例2: transferFinishedTransactions
function transferFinishedTransactions($account, $plannedTransaction)
{
$now = new Date();
$date = new Date($plannedTransaction->getBeginDate());
$dayOfMonth = $date->getDay();
//While we are before now and the end date of this transaction
while (!$date->after($now) && !$date->after(is_null($tmp = $plannedTransaction->getEndDate()) ? new Date('9999-12-31') : $tmp)) {
$account->addFinishedTransaction($plannedTransaction->getAmount(), $plannedTransaction->getTitle(), $plannedTransaction->getDescription(), new Date($date), $plannedTransaction->getTransactionPartner(), $plannedTransaction->getCategory(), $plannedTransaction->getOutsideCapital(), false, true);
//do the date calculation
switch ($plannedTransaction->getRepeatUnit()) {
case 'day':
$date->addSeconds($plannedTransaction->getRepeatFrequency() * 24 * 60 * 60);
break;
case 'week':
$date->addSeconds($plannedTransaction->getRepeatFrequency() * 7 * 24 * 60 * 60);
break;
case 'month':
//Set the month
$date = new Date(Date_Calc::endOfMonthBySpan($plannedTransaction->getRepeatFrequency(), $date->getMonth(), $date->getYear(), '%Y-%m-%d'));
//And count back as far as the last valid day of this month
while ($date->getDay() > $dayOfMonth) {
$date->subtractSeconds(24 * 60 * 60);
}
break;
case 'year':
$newYear = $date->getYear() + $plannedTransaction->getRepeatFrequency();
if ($dayOfMonth == 29 && $date->getMonth() == 2 && !Date_Calc::isLeapYear($newYear)) {
$date->setDay(28);
} else {
$date->setDay($dayOfMonth);
}
$date->setYear($newYear);
break;
default:
throw new BadgerException('Account', 'IllegalRepeatUnit', $plannedTransaction->getRepeatUnit());
exit;
}
}
}
示例3: previousOccurence
private function previousOccurence($date, $start = null)
{
if (is_null($start)) {
$start = $this->beginDate;
}
$dayOfMonth = $start->getDay();
//do the date calculation
switch ($this->repeatUnit) {
case 'day':
$date->subtractSeconds($this->repeatFrequency * 24 * 60 * 60);
break;
case 'week':
$date->subtractSeconds($this->repeatFrequency * 7 * 24 * 60 * 60);
break;
case 'month':
//Set the month
$date = new Date(Date_Calc::endOfMonthBySpan(-$this->repeatFrequency, $date->getMonth(), $date->getYear(), '%Y-%m-%d'));
//And count back as far as the last valid day of this month
while ($date->getDay() > $dayOfMonth) {
$date->subtractSeconds(24 * 60 * 60);
}
break;
case 'year':
$newYear = $date->getYear() - $this->repeatFrequency;
if ($dayOfMonth == 29 && $date->getMonth() == 2 && !Date_Calc::isLeapYear($newYear)) {
$date->setDay(28);
} else {
$date->setDay($dayOfMonth);
}
$date->setYear($newYear);
break;
default:
throw new BadgerException('Account', 'IllegalRepeatUnit', $this->repeatUnit);
exit;
}
//switch
return $date;
}
示例4: while
$currentAccount->setOrder($order);
while ($currentTransaction = $currentAccount->getNextTransaction()) {
$date = $currentTransaction->getValutaDate();
if (is_null($date)) {
continue;
}
switch ($type) {
case 'w':
$dateKey = $date->getYear() . '-' . sprintf('%02d', $date->getWeekOfYear());
$beginDate = new Date(Date_Calc::beginOfWeek($date->getDay(), $date->getMonth(), $date->getYear(), '%Y-%m-%d'));
$endDate = new Date(Date_Calc::endOfWeek($date->getDay(), $date->getMonth(), $date->getYear(), '%Y-%m-%d'));
break;
case 'm':
$dateKey = $date->getYear() . '-' . sprintf('%02d', $date->getMonth());
$beginDate = new Date(Date_Calc::beginOfMonth($date->getMonth(), $date->getYear(), '%Y-%m-%d'));
$endDate = new Date(Date_Calc::endOfMonthBySpan(0, $date->getMonth(), $date->getYear(), '%Y-%m-%d'));
break;
case 'q':
$dateKey = $date->getYear() . '-' . $date->getQuarterOfYear();
switch ($date->getQuarterOfYear()) {
case 1:
$beginDate = new Date($date->getYear() . '-01-01');
$endDate = new Date($date->getYear() . '-03-31');
break;
case 2:
$beginDate = new Date($date->getYear() . '-04-01');
$endDate = new Date($date->getYear() . '-06-30');
break;
case 3:
$beginDate = new Date($date->getYear() . '-07-01');
$endDate = new Date($date->getYear() . '-09-30');
示例5: transferFormerFinishedTransactions
function transferFormerFinishedTransactions($account)
{
global $us;
if ($us->getProperty('autoExpandPlannedTransactions') == false) {
return;
}
$now = new Date();
$now->setHour(0);
$now->setMinute(0);
$now->setSecond(0);
$account->setType('planned');
$account->setFilter(array(array('key' => 'beginDate', 'op' => 'le', 'val' => $now)));
try {
$lastInsertDate = $us->getProperty('Account_' . $account->getId() . '_LastTransferFormerFinishedTransactions');
} catch (BadgerException $ex) {
$lastInsertDate = new Date('1000-01-01');
}
$us->setProperty('Account_' . $account->getId() . '_LastTransferFormerFinishedTransactions', $now);
if (!$lastInsertDate->before($now)) {
return;
}
while ($currentTransaction = $account->getNextPlannedTransaction()) {
$date = new Date($currentTransaction->getBeginDate());
$dayOfMonth = $date->getDay();
//While we are before now and the end date of this transaction
while (!$date->after($now) && !$date->after(is_null($tmp = $currentTransaction->getEndDate()) ? new Date('9999-12-31') : $tmp)) {
if ($date->after($lastInsertDate)) {
$account->addFinishedTransaction($currentTransaction->getAmount(), $currentTransaction->getTitle(), $currentTransaction->getDescription(), new Date($date), $currentTransaction->getTransactionPartner(), $currentTransaction->getCategory(), $currentTransaction->getOutsideCapital(), false, true);
}
//do the date calculation
switch ($currentTransaction->getRepeatUnit()) {
case 'day':
$date->addSeconds($currentTransaction->getRepeatFrequency() * 24 * 60 * 60);
break;
case 'week':
$date->addSeconds($currentTransaction->getRepeatFrequency() * 7 * 24 * 60 * 60);
break;
case 'month':
//Set the month
$date = new Date(Date_Calc::endOfMonthBySpan($currentTransaction->getRepeatFrequency(), $date->getMonth(), $date->getYear(), '%Y-%m-%d'));
//And count back as far as the last valid day of this month
while ($date->getDay() > $dayOfMonth) {
$date->subtractSeconds(24 * 60 * 60);
}
break;
case 'year':
$newYear = $date->getYear() + $currentTransaction->getRepeatFrequency();
if ($dayOfMonth == 29 && $date->getMonth() == 2 && !Date_Calc::isLeapYear($newYear)) {
$date->setDay(28);
} else {
$date->setDay($dayOfMonth);
}
$date->setYear($newYear);
break;
default:
throw new BadgerException('Account', 'IllegalRepeatUnit', $currentTransaction->getRepeatUnit());
exit;
}
}
}
}
示例6: compare
compare('20000201', Date_Calc::beginOfMonthBySpan(0, 2, 2000), 'beginOfMonthBySpan 8');
compare('20000301', Date_Calc::beginOfMonthBySpan(1, 2, 2000), 'beginOfMonthBySpan 9');
compare('20010301', Date_Calc::beginOfMonthBySpan(13, 2, 2000), 'beginOfMonthBySpan 10');
compare('20010301', Date_Calc::beginOfMonthBySpan('13', '02', '2000'), 'beginOfMonthBySpan 10 str');
compare('19991031', Date_Calc::endOfMonthBySpan(-13, 11, 2000), 'endOfMonthBySpan 1');
compare('20001031', Date_Calc::endOfMonthBySpan(-1, 11, 2000), 'endOfMonthBySpan 2');
compare('20001130', Date_Calc::endOfMonthBySpan(0, 11, 2000), 'endOfMonthBySpan 3');
compare('20001231', Date_Calc::endOfMonthBySpan(1, 11, 2000), 'endOfMonthBySpan 4');
compare('20011231', Date_Calc::endOfMonthBySpan(13, 11, 2000), 'endOfMonthBySpan 5');
compare('19990131', Date_Calc::endOfMonthBySpan('-13', '02', '2000'), 'endOfMonthBySpan 6 str');
compare('19990131', Date_Calc::endOfMonthBySpan(-13, 2, 2000), 'endOfMonthBySpan 6');
compare('20000131', Date_Calc::endOfMonthBySpan(-1, 2, 2000), 'endOfMonthBySpan 7');
compare('20000229', Date_Calc::endOfMonthBySpan(0, 2, 2000), 'endOfMonthBySpan 8');
compare('20000331', Date_Calc::endOfMonthBySpan(1, 2, 2000), 'endOfMonthBySpan 9');
compare('20010331', Date_Calc::endOfMonthBySpan(13, 2, 2000), 'endOfMonthBySpan 10');
compare('20010331', Date_Calc::endOfMonthBySpan('13', '02', '2000'), 'endOfMonthBySpan 10 str');
compare(3, Date_Calc::firstOfMonthWeekday(11, 2000), 'firstOfMonthWeekday');
compare(3, Date_Calc::firstOfMonthWeekday('11', '2000'), 'firstOfMonthWeekday str');
compare('20050101', Date_Calc::NWeekdayOfMonth(1, 6, 1, 2005), 'NWeekdayOfMonth 161');
compare('20050102', Date_Calc::NWeekdayOfMonth(1, 0, 1, 2005), 'NWeekdayOfMonth 101');
compare('20050103', Date_Calc::NWeekdayOfMonth(1, 1, 1, 2005), 'NWeekdayOfMonth 111');
compare('20050104', Date_Calc::NWeekdayOfMonth(1, 2, 1, 2005), 'NWeekdayOfMonth 121');
compare('20050105', Date_Calc::NWeekdayOfMonth(1, 3, 1, 2005), 'NWeekdayOfMonth 131');
compare('20050106', Date_Calc::NWeekdayOfMonth(1, 4, 1, 2005), 'NWeekdayOfMonth 141');
compare('20050107', Date_Calc::NWeekdayOfMonth(1, 5, 1, 2005), 'NWeekdayOfMonth 151');
compare('20050108', Date_Calc::NWeekdayOfMonth('2', '6', '01', '2005'), 'NWeekdayOfMonth 261');
compare('20050109', Date_Calc::NWeekdayOfMonth('2', '0', '01', '2005'), 'NWeekdayOfMonth 201');
compare('20050110', Date_Calc::NWeekdayOfMonth('2', '1', '01', '2005'), 'NWeekdayOfMonth 211');
compare('20050111', Date_Calc::NWeekdayOfMonth('2', '2', '01', '2005'), 'NWeekdayOfMonth 221');
compare('20050112', Date_Calc::NWeekdayOfMonth('2', '3', '01', '2005'), 'NWeekdayOfMonth 231');
compare('20050113', Date_Calc::NWeekdayOfMonth('2', '4', '01', '2005'), 'NWeekdayOfMonth 241');