X-Git-Url: http://git.datanom.net/flask-test.git/blobdiff_plain/db4f0ba9d4aec596f179335f1d86b3dd2bb206c6..163c4d87c8cefd45e8c8836daa28c53956be1e1a:/app/momentjs.py?ds=inline diff --git a/app/momentjs.py b/app/momentjs.py new file mode 100644 index 0000000..0939d3e --- /dev/null +++ b/app/momentjs.py @@ -0,0 +1,17 @@ +from jinja2 import Markup + +class momentjs(object): + def __init__(self, timestamp): + self.timestamp = timestamp + + def render(self, format): + return Markup("" % (self.timestamp.strftime("%Y-%m-%dT%H:%M:%S Z"), format)) + + def format(self, fmt): + return self.render("format(\"%s\")" % fmt) + + def calendar(self): + return self.render("calendar()") + + def fromNow(self): + return self.render("fromNow()")