# -*- coding: utf-8 -*- from genshi.builder import tag from genshi import Markup from trac.wiki.macros import WikiMacroBase from trac.util.translation import _ from trac.web.chrome import add_script from datetime import datetime, timedelta from pkg_resources import resource_filename class CountDownMacro(WikiMacroBase): """Renders an overview of active RendezVouses""" revision = "$Rev$" url = "$URL$" def expand_macro(self, formatter, name, content): try: event_datetime = datetime(*tuple(time.strptime("2010, 07, 16", "%Y, %m, %d"))[:3]) except Exception: return "" dt = event_datetime - datetime.utcnow() hours = "%d:%d" % (dt.seconds / 3600, (dt.seconds % 3600) / 60) days = str(dt.days) return Markup("""

CountDown

%s Tage %s
""" % (days, hours))