Mais coisas, estatisticas
This commit is contained in:
@@ -1,2 +1,32 @@
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def is_empty(_str: str) -> bool:
|
||||
return len(_str.strip(" ")) == 0
|
||||
|
||||
|
||||
def toDateTime(dt: str) -> datetime | int:
|
||||
if len(dt) == 0:
|
||||
return -1
|
||||
try:
|
||||
return datetime.strptime(dt, "%Y-%m-%d")
|
||||
except ValueError:
|
||||
return -1
|
||||
|
||||
|
||||
def toFloat(v: str) -> float:
|
||||
if len(v) == 0:
|
||||
return -1.0
|
||||
try:
|
||||
return float(v)
|
||||
except ValueError:
|
||||
return -1.0
|
||||
|
||||
|
||||
def toInt(v: str) -> int | None:
|
||||
if len(v) == 0:
|
||||
return None
|
||||
try:
|
||||
return int(v)
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user