diff --git a/dateutils.py b/dateutils.py index e84bef6..cb611cc 100644 --- a/dateutils.py +++ b/dateutils.py @@ -1,5 +1,5 @@ from datetime import datetime - +from typing import Optional def format_month(month: int) -> str: if month == 1: @@ -32,3 +32,10 @@ def format_month(month: int) -> str: def format(date: datetime) -> str: return f'{date.day} {format_month(date.month)} {date.year} à {date.hour:02}h{date.minute:02}' + + +def format_short(date: Optional[datetime]) -> str: + if date is None: + return 'XX/XX/XXXX' + + return f'{date.day:02}/{date.month:02}/{date.year}' diff --git a/db.py b/db.py index 63d69cd..a3f3bdd 100755 --- a/db.py +++ b/db.py @@ -118,6 +118,9 @@ class Calibration: def get_pretty_date(self) -> str: return dateutils.format(self.validated_date) + def get_pretty_short_date(self) -> str: + return dateutils.format_short(self.validated_date) + Calibration.Dummy = Calibration(-1, CalibrationState.Empty, None) diff --git a/templates/base.html b/templates/base.html index b5c7cd9..8bbfad6 100644 --- a/templates/base.html +++ b/templates/base.html @@ -43,7 +43,7 @@ étalonnage - validé + validé le {{ calibration.get_pretty_short_date() }}