Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
integration
prechecker
Commits
02edbe1e
Commit
02edbe1e
authored
Mar 15, 2017
by
jun
Browse files
MDL-57658 calendar: Remove BYDAY filtering dependence on NumberFormatter
parent
484eeebc
Changes
1
Hide whitespace changes
Inline
Side-by-side
calendar/classes/rrule_manager.php
View file @
02edbe1e
...
...
@@ -28,7 +28,6 @@ use calendar_event;
use
DateInterval
;
use
DateTime
;
use
moodle_exception
;
use
NumberFormatter
;
use
stdClass
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
...
...
@@ -1049,9 +1048,6 @@ class rrule_manager {
$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'
);
...
...
@@ -1073,23 +1069,19 @@ class rrule_manager {
}
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
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment