From d37b031139954e0869b187b885c1b40c967b15ed Mon Sep 17 00:00:00 2001 From: Nils Date: Tue, 17 Oct 2023 21:08:21 +0200 Subject: [PATCH] replace next meeting days with php script. no more manual adjusting needed --- index.html => index.php | 23 +++++++--------- third_wednesday.php | 60 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 14 deletions(-) rename index.html => index.php (92%) create mode 100644 third_wednesday.php diff --git a/index.html b/index.php similarity index 92% rename from index.html rename to index.php index 424d506..7f0f260 100644 --- a/index.html +++ b/index.php @@ -1,3 +1,9 @@ + + @@ -175,21 +181,10 @@
-

Termine18.10.2023 19:00 Uhr

+

Termine 19:00 Uhr

Jeder Dritte Mittwoch im Monat (außer Dezember):
- 15.11. - 17.1. - 21.2. - 20.3. - 17.4. - 15.5. - 19.6. - 17.7. - 21.8. - 18.9. - 16.10. - 20.11. +

@@ -231,7 +226,7 @@
-

Nächstes Treffen: 18.10.2023

+

Nächstes Treffen:

diff --git a/third_wednesday.php b/third_wednesday.php new file mode 100644 index 0000000..b835df8 --- /dev/null +++ b/third_wednesday.php @@ -0,0 +1,60 @@ +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; +} + +?>