mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
olson_parse_on() now parses as agreed for the new timezone settings.
This commit is contained in:
parent
3f95436073
commit
01b4c10789
1 changed files with 36 additions and 11 deletions
|
@ -455,16 +455,27 @@ function olson_parse_offset ($offset) {
|
||||||
/***
|
/***
|
||||||
*** olson_parse_on_($on)
|
*** olson_parse_on_($on)
|
||||||
***
|
***
|
||||||
*** see `man zic`. This function translated the following formats
|
*** see `man zic`. This function translates the following formats
|
||||||
*** 5 the fifth of the month
|
*** 5 the fifth of the month
|
||||||
*** lastSun the last Sunday in the month
|
*** lastSun the last Sunday in the month
|
||||||
*** lastMon the last Monday in the month
|
*** lastMon the last Monday in the month
|
||||||
*** Sun>=8 first Sunday on or after the eighth
|
*** Sun>=8 first Sunday on or after the eighth
|
||||||
*** Sun<=25 last Sunday on or before the 25th
|
*** Sun<=25 last Sunday on or before the 25th
|
||||||
***
|
***
|
||||||
*** to a moodle friendly format. Returns
|
*** to a moodle friendly format. Returns an array with:
|
||||||
*** array(index =>$index, day =>$day)
|
|
||||||
***
|
***
|
||||||
|
*** startday: the day of the month that we start counting from.
|
||||||
|
*** if negative, it means we start from that day and
|
||||||
|
*** count backwards. since -1 would be meaningless,
|
||||||
|
*** it means "end of month and backwards".
|
||||||
|
*** weekday: the day of the week that we must find. we will
|
||||||
|
*** scan days from the startday until we find the
|
||||||
|
*** first such weekday. 0...6 = Sun...Sat.
|
||||||
|
*** -1 means that any day of the week will do,
|
||||||
|
*** effectively ending the search on startday.
|
||||||
|
*** skipweeks:after finding our end day as outlined above,
|
||||||
|
*** skip this many weeks. this enables us to find
|
||||||
|
*** "the second sunday >= 10". usually will be 0.
|
||||||
*/
|
*/
|
||||||
function olson_parse_on ($on) {
|
function olson_parse_on ($on) {
|
||||||
|
|
||||||
|
@ -475,8 +486,9 @@ function olson_parse_on ($on) {
|
||||||
'sat' => 6);
|
'sat' => 6);
|
||||||
|
|
||||||
if(is_numeric($on)) {
|
if(is_numeric($on)) {
|
||||||
$rule['index'] = $on;
|
$rule['startday'] = intval($on); // Start searching from that day
|
||||||
$rule['day'] = -1;
|
$rule['weekday'] = -1; // ...and stop there, no matter what weekday
|
||||||
|
$rule['skipweeks'] = 0; // Don't skip any weeks.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$on = strtolower($on);
|
$on = strtolower($on);
|
||||||
|
@ -486,18 +498,31 @@ function olson_parse_on ($on) {
|
||||||
trigger_error('Unknown last weekday: '.substr($on, 4));
|
trigger_error('Unknown last weekday: '.substr($on, 4));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$rule['index'] = -1;
|
$rule['startday'] = -1 // Start from end of month
|
||||||
$rule['day'] = $days[substr($on, 4)];
|
$rule['weekday'] = $days[substr($on, 4)]; // Find the first such weekday
|
||||||
|
$rule['skipweeks'] = 0; // Don't skip any weeks.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(substr($on, 3, 2) == '>=') {
|
else if(substr($on, 3, 2) == '>=') {
|
||||||
// e.g. Sun>=8
|
// e.g. Sun>=8
|
||||||
if(!isset($days[substr($on, 0, 3)])) {
|
if(!isset($days[substr($on, 0, 3)])) {
|
||||||
trigger_error('Unknown last weekday: '.substr($on, 0, 3));
|
trigger_error('Unknown >= weekday: '.substr($on, 0, 3));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$rule['index'] = substr($on, 5);
|
$rule['startday'] = intval(substr($on, 5)); // Start from that day of the month
|
||||||
$rule['day'] = $days[substr($on, 0, 3)];
|
$rule['weekday'] = $days[substr($on, 0, 3)]; // Find the first such weekday
|
||||||
|
$rule['skipweeks'] = 0; // Don't skip any weeks.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(substr($on, 3, 2) == '<=') {
|
||||||
|
// e.g. Sun<=25
|
||||||
|
if(!isset($days[substr($on, 0, 3)])) {
|
||||||
|
trigger_error('Unknown <= weekday: '.substr($on, 0, 3));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$rule['startday'] = -intval(substr($on, 5)); // Start from that day of the month; COUNT BACKWARDS (minus sign)
|
||||||
|
$rule['weekday'] = $days[substr($on, 0, 3)]; // Find the first such weekday
|
||||||
|
$rule['skipweeks'] = 0; // Don't skip any weeks.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue