[wiki] Pour calculer son âge
This commit is contained in:
parent
5b839ef541
commit
0c14649a2c
1 changed files with 18 additions and 0 deletions
18
wiki/macro/BirthDate.py
Normal file
18
wiki/macro/BirthDate.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/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))
|
Loading…
Add table
Add a link
Reference in a new issue