#!/usr/bin/env python3 """Generate a static HTML page showing Louis and Maël's age in days and weeks (FR/EN/JA).""" import json from datetime import date, datetime, timezone CHILDREN = [ {"name": "Louis", "birthdate": date(2018, 10, 14), "emoji": "👦", "color": "#667eea"}, {"name": "Maël", "birthdate": date(2020, 6, 24), "emoji": "🧒", "color": "#764ba2"}, ] TODAY = date.today() # UI translations I18N = { "fr": { "title": "Combien de jours ? — Louis & Maël", "heading": "📅 Combien de jours ?", "born": "né le {date}", "days": "jours", "weeks": "semaines", "years": "ans", "months": "mois", "extra_days": "+ {n} j", "updated": "Mis à jour le", }, "en": { "title": "How Many Days? — Louis & Maël", "heading": "📅 How Many Days?", "born": "born on {date}", "days": "days", "weeks": "weeks", "years": "years", "months": "months", "extra_days": "+ {n} d", "updated": "Updated on", }, "ja": { "title": "何日経った? — Louis & Maël", "heading": "📅 何日経った?", "born": "{date} 生まれ", "days": "日", "weeks": "週間", "years": "歳", "months": "ヶ月", "extra_days": "+ {n} 日", "updated": "更新日時", }, } # Month names for date formatting MONTHS = { "fr": ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"], "en": ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], "ja": ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"], } I18N_JSON = json.dumps(I18N, ensure_ascii=False) MONTHS_JSON = json.dumps(MONTHS, ensure_ascii=False) def calculate_age(birthdate): delta = TODAY - birthdate total_days = delta.days weeks = total_days // 7 extra_days = total_days % 7 years = TODAY.year - birthdate.year months = TODAY.month - birthdate.month if TODAY.day < birthdate.day: months -= 1 if months < 0: years -= 1 months += 12 return { "total_days": total_days, "weeks": weeks, "extra_days": extra_days, "years": years, "months": months, } def generate_html(): now = datetime.now(timezone.utc) cards_html = [] for child in CHILDREN: age = calculate_age(child["birthdate"]) birth_y = child["birthdate"].year birth_m = child["birthdate"].month birth_d = child["birthdate"].day card = f"""

{child['emoji']} {child['name']}

{age['total_days']:,} jours
{age['weeks']:,} semaines
{age['years']} ans
{age['months']} mois
""" cards_html.append(card) cards = "\n".join(cards_html) html = f""" Combien de jours ? — Louis & Maël

📅 Combien de jours ?

{cards}
""" return html if __name__ == "__main__": html = generate_html() output_path = "/home/jerome/hermes-sites/combien-jour.hidrago.click/index.html" with open(output_path, "w", encoding="utf-8") as f: f.write(html) print(f"Age page generated at {output_path}")