Skip to content

Commit

Permalink
Add script to generate Freies Hacken Events
Browse files Browse the repository at this point in the history
  • Loading branch information
timherrm committed Nov 9, 2023
1 parent 75698ff commit efd42af
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tools/generate_freieshacken_events.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import os
import datetime


# Function to generate the markdown content for a specific date
def generate_markdown_file(year, month, day):
markdown_content = f"""---
layout: event
title: "Freies Hacken"
event_date: {year}-{month:02d}-{day:02d}
---
**Wann: 19:30 Uhr**\\
**Wo: Netz39 e.V.**
Jeden Mittwoch treffen wir uns zum Basteln, Reparieren, Kochen und Ideen austauschen. Gäste sind gerne willkommen
Bitte beachtet, dass jede dritte Woche unser Stammtisch ist, wo wir über vereinsinterne Sachen reden und erst anschließend zum gemütlichen Abend übergehen.
"""

folder_path = "_events"
filename = f"{year}-{month:02d}-{day:02d}_n39_freies_hacken.md"
file_path = os.path.join(folder_path, filename)

with open(file_path, 'w', encoding='utf-8') as file:
file.write(markdown_content)

print(f"Markdown file '{filename}' generated successfully in the _events folder!")


# Input year
input_year = int(input("Enter the year: "))

# Calculate Wednesdays in weeks divisible by three
for month in range(1, 13):
for day in range(1, 32):
try:
# Generate a date object
current_date = datetime.date(input_year, month, day)

# Check if the date is a Wednesday
if current_date.weekday() == 2:
generate_markdown_file(input_year, month, day)

except ValueError:
# If the day is out of range for the month, skip to the next month
pass

0 comments on commit efd42af

Please sign in to comment.