commit iniziale

This commit is contained in:
2024-11-16 15:23:00 +01:00
parent 97abdc8dfa
commit 968d1c3985
9 changed files with 123 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
"""Funzioni per convertire formato data
"""
import datetime
def dateFmt(date):
t = date.replace("/", "-")
try:
datetime.datetime.strptime(t, "%Y-%m-%d")
return t
except ValueError:
d = datetime.datetime.strptime(t, "%d-%m-%Y")
return datetime.datetime.strftime(d, "%Y-%m-%d")
def dateTimeFmt(date):
t = date.replace("/", "-")
try:
datetime.datetime.strptime(t, "%Y-%m-%d %H:%M:%S")
return t
except ValueError:
d = datetime.datetime.strptime(t, "%d-%m-%Y %H:%M:%S")
return datetime.datetime.strftime(d, "%Y-%m-%d %H:%M:%S")