generated from sylhare/Type-on-Strap
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to generate Freies Hacken Events
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |