Skip to content

Commit

Permalink
Update scraper.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
BfB-Schenefeld committed Apr 22, 2024
1 parent f36e54f commit b55793f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions scraper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@

# Funktion zum Formatieren des Datums
def format_date(day, month, year)
# Führende Nullen hinzufügen, falls nötig
day = day.rjust(2, '0')
month = month.rjust(2, '0')
# Stelle sicher, dass Tag und Monat als Strings behandelt werden
day_s = day.to_s.rjust(2, '0')
month_s = month.to_s.rjust(2, '0')

date_string = "#{day}.#{month}.#{year}"
date = Date.parse(date_string)
# Wochentag abkürzen (z.B. "Di" für Dienstag) und Datum formatieren
# Erstelle ein Datum-Objekt mit dem formatierten Tag und Monat
date = Date.new(year.to_i, month_s.to_i, day_s.to_i)
# Formatierung des Datums im gewünschten Format
date.strftime("%a., %d.%m.%Y") # Z.B. "Di., 05.03.2024"
rescue ArgumentError
nil # Bei ungültigem Datum wird nil zurückgegeben
Expand Down

0 comments on commit b55793f

Please sign in to comment.