2013-01-08 07:18:12 +00:00
|
|
|
from jinja2 import Markup
|
|
|
|
|
2014-09-19 14:47:13 +00:00
|
|
|
|
2013-07-06 17:32:59 +00:00
|
|
|
class momentjs(object):
|
2013-01-08 07:18:12 +00:00
|
|
|
def __init__(self, timestamp):
|
|
|
|
self.timestamp = timestamp
|
|
|
|
|
|
|
|
def render(self, format):
|
2014-09-19 14:47:13 +00:00
|
|
|
return Markup(
|
|
|
|
"<script>\ndocument.write(moment(\"%s\").%s);\n</script>" %
|
|
|
|
(self.timestamp.strftime("%Y-%m-%dT%H:%M:%S Z"), format))
|
2013-01-08 07:18:12 +00:00
|
|
|
|
|
|
|
def format(self, fmt):
|
|
|
|
return self.render("format(\"%s\")" % fmt)
|
|
|
|
|
|
|
|
def calendar(self):
|
|
|
|
return self.render("calendar()")
|
|
|
|
|
|
|
|
def fromNow(self):
|
|
|
|
return self.render("fromNow()")
|