mirror of https://codeberg.org/Sonoj/osamc.de
61 lines
1.7 KiB
PHP
61 lines
1.7 KiB
PHP
<?php
|
|
|
|
function nextThirdWednesday() {
|
|
// Set the default time zone to your desired one
|
|
date_default_timezone_set('Europe/Berlin');
|
|
|
|
$date = new DateTime( 'third wednesday of this month, 17:00' );
|
|
if( date_create()->diff( $date )->invert )
|
|
{
|
|
$date = new DateTime( 'third wednesday of next month, 17:00' );
|
|
}
|
|
|
|
|
|
if ($date->format('m') == '12') {
|
|
// If it's December, advance to January of the following year
|
|
$date->modify('third wednesday of January next year');
|
|
$date->modify('-1 day'); // not sure why.
|
|
}
|
|
|
|
|
|
$nextThirdWednesdayFormatted = $date->format('d.m.y');
|
|
return $nextThirdWednesdayFormatted;
|
|
}
|
|
|
|
function listNextElevenThirdWendesdays() {
|
|
date_default_timezone_set('Europe/Berlin');
|
|
|
|
//Start with the actual next meeting date, that is already calculated by another function already.
|
|
$date = new DateTime( 'third wednesday of this month, 17:00' );
|
|
if( date_create()->diff( $date )->invert )
|
|
{
|
|
$date = new DateTime( 'third wednesday of next month, 17:00' );
|
|
}
|
|
|
|
if ($date->format('m') == '12') {
|
|
// If it's December, advance to January of the following year
|
|
$date->modify('third wednesday of January next year');
|
|
$date->modify('-1 day'); // not sure why.
|
|
}
|
|
|
|
|
|
$result = "";
|
|
|
|
for ($i=0; $i < 11; $i++) {
|
|
|
|
$date->modify('third wednesday of next month');
|
|
//Again:
|
|
if ($date->format('m') == '12') {
|
|
// If it's December, advance to January of the following year
|
|
$date->modify('third wednesday of January next year');
|
|
$date->modify('-1 day'); // not sure why.
|
|
}
|
|
|
|
$result = $result . " " . $date->format('d.m');
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
?>
|