view MoinMoin/macro/ @ 1767:54be46b8a0b4

flask ext import change Flask extensions should urge users to import from instead of flask_foo or flaskext_foo.
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 02 Sep 2012 21:53:25 +0200
parents 4ac437141bbe
children 87272c032485
line wrap: on
line source
# Copyright: 2008-2011 MoinMoin:ThomasWaldmann
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

MoinMoin DateTime macro - outputs the date and time for some specific point in time,
adapted to the TZ settings of the user viewing the content.

import time
from datetime import datetime

from flask import g as flaskg
from flask.ext.babel import format_datetime

from MoinMoin.macro.Date import MacroDateTimeBase

class Macro(MacroDateTimeBase):
    def macro(self, content, arguments, page_url, alternative):
        if arguments is None:
            tm = time.time() # always UTC
            stamp = arguments[0]
            tm = self.parse_time(stamp)
        return format_datetime(datetime.utcfromtimestamp(tm))