diff --git a/wiki/macro/BirthDate.py b/wiki/macro/BirthDate.py new file mode 100644 index 00000000..dd2ab96b --- /dev/null +++ b/wiki/macro/BirthDate.py @@ -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))