python:snippets:datum
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
| python:snippets:datum [2025/05/11 21:32] – franz | python:snippets:datum [2025/05/11 22:12] (aktuell) – [Formatiere einen Datumstring ins europäische Format] franz | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| ====== Datumsfunktionen ====== | ====== Datumsfunktionen ====== | ||
| - | ===== Formatiere einen Datumstring ins europäische Format ===== | + | ==== Formatiere einen Datumstring ins europäische Format ==== |
| + | |||
| + | Zweck: Konvertiert ein Datum aus dem ISO-Format (YYYY-MM-DD) in das europäische Format (TT.MM.JJJJ) | ||
| + | |||
| + | < | ||
| + | def format_datum_eu(datum_str: | ||
| + | |||
| + | """ | ||
| + | Konvertiert ein Datum aus dem ISO-Format (YYYY-MM-DD) in das europäische Format (TT.MM.JJJJ). | ||
| + | Args: | ||
| + | datum_str (str): Datum im Format YYYY-MM-DD. | ||
| + | Returns: | ||
| + | str: Datum im Format TT.MM.JJJJ. Falls die Konvertierung fehlschlägt, | ||
| + | """ | ||
| + | try: | ||
| + | datum = datetime.strptime(datum_str, | ||
| + | return datum.strftime(" | ||
| + | except ValueError: | ||
| + | return datum_str | ||
| + | |||
| + | </ | ||
python/snippets/datum.1746991958.txt.gz · Zuletzt geändert: von franz