Commit 0c14649a authored by Vincent Le gallic's avatar Vincent Le gallic

[wiki] Pour calculer son âge

parent 5b839ef5
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from MoinMoin.wikiutil import escape
import time
import datetime
import re
def execute(macro, text):
year, month, day = text.split(",")
y, m, d = int(year), int(month), int(day)
now = datetime.datetime(*time.localtime()[:6])
birthdate = datetime.datetime(now.year, m, d)
age = now.year - y
if now < birthdate:
age -= 1
return macro.formatter.text(str(age))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment