diff --git a/app/__init__.py b/app/__init__.py index bd9992f..d22d506 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -31,6 +31,19 @@ def _migrate_db(app): conn.commit() +_JOURS_FR = ["lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche"] +_MOIS_FR = ["", "janvier", "février", "mars", "avril", "mai", "juin", + "juillet", "août", "septembre", "octobre", "novembre", "décembre"] + + +def _date_fr(d): + """Formate une date en français : 'mercredi 11 mars 2026'.""" + from datetime import date as date_type + jour = _JOURS_FR[d.weekday()] + mois = _MOIS_FR[d.month] + return f"{jour} {d.day} {mois} {d.year}" + + def create_app(config_path=None): app = Flask(__name__, instance_relative_config=True) @@ -50,6 +63,7 @@ def create_app(config_path=None): app.config["TOML"] = {} db.init_app(app) + app.jinja_env.filters["date_fr"] = _date_fr from app.routes.dashboard import bp as dashboard_bp from app.routes.entries import bp as entries_bp diff --git a/app/templates/dashboard.html b/app/templates/dashboard.html index 63a0bfa..45066d1 100644 --- a/app/templates/dashboard.html +++ b/app/templates/dashboard.html @@ -4,7 +4,7 @@

- Aujourd'hui — {{ today.strftime('%A %d %B %Y') }} + Aujourd'hui — {{ today | date_fr }}

{% if today_entry %}

{{ today_entry.day_type }} — {{ today_entry.total_hours_str() }}

diff --git a/app/templates/entry_list.html b/app/templates/entry_list.html index 86bd019..13f147d 100644 --- a/app/templates/entry_list.html +++ b/app/templates/entry_list.html @@ -12,7 +12,7 @@ {% for entry in entries %}
-

{{ entry.date.strftime('%a %d %b %Y') }}

+

{{ entry.date | date_fr }}

{{ entry.day_type }} {% if entry.time_slots %} — {{ entry.total_hours_str() }}{% endif %}