= 4 && $f != 'treff.md' && $f != 'topictreff.md' && $f != 'repaircafe.md' && $f != 'brunch.md') $output[] = $f; } return $output; } function generate_event_list($limit = -1) { $events = scan_for_events(); $output = ""; if ($limit == -1) { foreach ($events as $event) { $lines = file(__DIR__ . '/../events/' . $event); $title = $lines[0]; $desc = $lines[1]; $date = $lines[2]; $veranstaltungsort = $lines[4]; $output .= '

'.$veranstaltungsort.'

'.$date.'

'.$title.'

'.$desc.'

'; } } else { if($limit > count($events)) $limit = count($events); for ($i = 0; $i < $limit; $i++) { $lines = file(__DIR__ . '/../events/' . $event); $title = $lines[0]; $desc = $lines[1]; $date = $lines[2]; $veranstaltungsort = $lines[4]; $output .= '

'.$veranstaltungsort.'

'.$date.'

'.$title.'

'.$desc.'

'; } } return $output; } function get_event_content($id) { $lines = file(__DIR__ . '/../events/' . str_replace('.', '', $id) . '.md'); $output = ""; $output .= '## Datum/Zeit'."\n\n"; $output .= $lines[2]."\n".$lines[3]."\n\n## Veranstaltungsort\n\n".$lines[4]."\n\n"; for ($i = 6; $i < count($lines); $i++) $output .= $lines[$i] . "\n"; return $output; } function get_next_topic() { $output = new stdClass(); $currentDate = new DateTime(); $next_topic = clone $currentDate; $next_topic->modify('second Tuesday of this month +1 week'); while ($next_topic->format('N') !== '2') { $next_topic->add(new DateInterval('P1D')); } $output->days = $currentDate->diff($next_topic)->days+1; $output->date = $next_topic->format('Y-m-d'); return $output; } function get_next_treff() { $output = new stdClass(); // Get current date and time $now = new DateTime(); // Find the next Friday $now->modify('next Friday'); // Calculate the number of days until the next Friday $diff = $now->diff(new DateTime()); $days_until = $diff->format('%a'); $output->days = $days_until+1; $output->date = $now->format('Y-m-d'); // Return an array with the count and date of the next Friday return $output; } function get_next_repaircafe() { $output = new stdClass(); $today = new DateTime(); $lastDayOfMonth = clone $today; $lastDayOfMonth->modify('last day of this month'); $lastThursday = clone $lastDayOfMonth; while ($lastThursday->format('w') != 4) { // Thursday is represented by 4 (0-6, where 0 is Sunday) $lastThursday->modify('-1 day'); } $daysUntilLastThursday = $today->diff($lastThursday)->days; $output->days = $daysUntilLastThursday; $output->date = $lastThursday->format('Y-m-d'); return $output; } function get_next_brunch() { $now = new DateTime(); if ($now->format('w') == 0) { $nextSunday = clone $now; } else { $nextSunday = new DateTime('next Sunday'); } $weekNumber = (int)$nextSunday->format('W'); $isEvenWeek = ($weekNumber % 2) == 0; if ($isEvenWeek) { $nextSunday->modify('+1 week'); } $differenz = $nextSunday->diff($now); $days = $differenz->days; $output = new stdClass(); $output->date = $nextSunday->format('Y-m-d'); $output->days = $days+1; return $output; } ?>