Added templatetags "monthname" and "ap_monthname" to Penfield, which turn month numbe...
authorKriti Godey <kriti.godey@gmail.com>
Wed, 7 Jul 2010 07:21:22 +0000 (12:51 +0530)
committerKriti Godey <kriti.godey@gmail.com>
Wed, 7 Jul 2010 07:21:22 +0000 (12:51 +0530)
contrib/penfield/templatetags/__init__.py [new file with mode: 0644]
contrib/penfield/templatetags/penfield.py [new file with mode: 0644]

diff --git a/contrib/penfield/templatetags/__init__.py b/contrib/penfield/templatetags/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/contrib/penfield/templatetags/penfield.py b/contrib/penfield/templatetags/penfield.py
new file mode 100644 (file)
index 0000000..3f4c2f4
--- /dev/null
@@ -0,0 +1,23 @@
+from django import template
+from django.utils.dates import MONTHS, MONTHS_AP
+
+register = template.Library()
+
+def monthname(value):
+       monthnum = int(value)
+       if 1 <= monthnum <= 12:
+               return MONTHS[monthnum]
+       else:
+               return value
+
+register.filter('monthname', monthname)
+
+def ap_monthname(value):
+       monthnum = int(value)
+       if 1 <= monthnum <= 12:
+               return MONTHS_AP[monthnum]
+       else:
+               return value
+
+register.filter('monthname', monthname)
+register.filter('ap_monthname', ap_monthname)