]> git.datanom.net - flask-test.git/blobdiff - app/momentjs.py
final
[flask-test.git] / app / momentjs.py
diff --git a/app/momentjs.py b/app/momentjs.py
new file mode 100644 (file)
index 0000000..0939d3e
--- /dev/null
@@ -0,0 +1,17 @@
+from jinja2 import Markup
+
+class momentjs(object):
+    def __init__(self, timestamp):
+        self.timestamp = timestamp
+
+    def render(self, format):
+        return Markup("<script>\ndocument.write(moment(\"%s\").%s);\n</script>" % (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()")
This page took 0.043063 seconds and 5 git commands to generate.