Skip to content

Commit

Permalink
Merge branch 'MDL-57658-master-integration-fix-2' of git://github.com…
Browse files Browse the repository at this point in the history
…/junpataleta/moodle
  • Loading branch information
andrewnicols committed Mar 15, 2017
2 parents 5fba3bd + 02edbe1 commit 6fcdbc7
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions calendar/classes/rrule_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use DateInterval;
use DateTime;
use moodle_exception;
use NumberFormatter;
use stdClass;

defined('MOODLE_INTERNAL') || die();
Expand Down Expand Up @@ -1049,9 +1048,6 @@ protected function filter_by_day($event, $eventdates, $until) {

$filteredbyday = [];

$formatter = new NumberFormatter('en_utf8', NumberFormatter::SPELLOUT);
$formatter->setTextAttribute(NumberFormatter::DEFAULT_RULESET, "%spellout-ordinal");

$bounds = $this->get_period_bounds_list($event->timestart, $until);

$nextmonthinterval = new DateInterval('P1M');
Expand All @@ -1073,23 +1069,19 @@ protected function filter_by_day($event, $eventdates, $until) {
} else if ($day->value > 0) {
// Positive value.
if ($this->freq === self::FREQ_YEARLY && empty($this->bymonth)) {
// Nth week day of the year.
$expecteddate = new DateTime($tmpdatetime->format('Y') . '-01-01');
$count = $day->value;
$expecteddate->modify("+$count $dayname");
if ($expecteddate->format('Y-m-d') === $tmpdatetime->format('Y-m-d')) {
$filteredbyday[] = $time;
break;
}
// Get the first day of the year.
$firstdaydate = $tmpdatetime->format('Y') . '-01-01';
} else {
// Nth week day of the month.
$expectedmonthyear = $tmpdatetime->format('F Y');
$expectedordinal = $formatter->format($day->value);
$expecteddate = new DateTime("$expectedordinal $dayname of $expectedmonthyear");
if ($expecteddate->format('Y-m-d') === $tmpdatetime->format('Y-m-d')) {
$filteredbyday[] = $time;
break;
}
// Get the first day of the month.
$firstdaydate = $tmpdatetime->format('Y-m') . '-01';
}
$expecteddate = new DateTime($firstdaydate);
$count = $day->value;
// Get the nth week day of the year/month.
$expecteddate->modify("+$count $dayname");
if ($expecteddate->format('Y-m-d') === $tmpdatetime->format('Y-m-d')) {
$filteredbyday[] = $time;
break;
}

} else {
Expand Down

0 comments on commit 6fcdbc7

Please sign in to comment.