Skip to content

Commit

Permalink
Remove unused function
Browse files Browse the repository at this point in the history
  • Loading branch information
campbell-m committed Nov 8, 2024
1 parent 9977616 commit 275977a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 40 deletions.
39 changes: 0 additions & 39 deletions web/functions.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1158,45 +1158,6 @@ function date_byday(int $timestamp) : string
}


// Converts a BYDAY (eg "2SU") value for a given year and month into a
// day of the month. Returns FALSE if the day does not exist (eg for "5SU"
// when there are only four Sundays in the month)
function byday_to_day(int $year, int $month, string $byday)
{
// First of all normalise the month and year, as we allow $month > 12
while ($month > 12)
{
$month -= 12;
$year++;
}
// Get the ordinal number and the day of the week
list('ordinal' => $ord, 'day' => $dow) = RFC5545::parseByday($byday);
// Get the starting day of the month
$start_dom = ($ord > 0) ? 1 : date('t', mktime(0, 0, 0, $month, 1, $year));
// Get the starting day of the week
$start_dow = date('w', mktime(0, 0, 0, $month, $start_dom, $year));
// Turn the BYDAY day of the week into an integer
$byday_dow = RFC5545::convertDayToOrd($dow);
// get the difference in days
$diff = $byday_dow - $start_dow;
$diff += ($ord > 0) ? DAYS_PER_WEEK : -DAYS_PER_WEEK;
$diff = $diff %DAYS_PER_WEEK;
// add in the weeks
$diff += ($ord > 0) ? ($ord - 1) * DAYS_PER_WEEK : ($ord + 1) * DAYS_PER_WEEK;

$day = $start_dom + $diff;

if (checkdate($month, $day, $year))
{
return $day;
}
else
{
return false;
}
}


// Returns TRUE if the time $hm1 is before $hm2
// $hm1 and $hm2 are associative arrays indexed by 'hours' and 'minutes'.
// The indices are chosen to allow the result of the PHP getdate() function
Expand Down
1 change: 0 additions & 1 deletion web/lib/MRBS/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public static function firstDayOfWeek(?string $timezone = null, ?string $locale
}


// TODO: replace usages of byday_to_day() with this method
// TODO: make $relative an object?
// Sets the day to $relative, where relative is an RFC5545 relative day,
// eg "-2SU". Returns FALSE if the relative day doesn't exist in this
Expand Down

0 comments on commit 275977a

Please sign in to comment.