From: Kriti Godey Date: Wed, 7 Jul 2010 07:21:22 +0000 (+0530) Subject: Added templatetags "monthname" and "ap_monthname" to Penfield, which turn month numbe... X-Git-Tag: philo-0.9~53^2~1^2 X-Git-Url: http://git.ithinksw.org/philo.git/commitdiff_plain/889f3b6a7bb05b60aba7059031b9f3238d0d2a60 Added templatetags "monthname" and "ap_monthname" to Penfield, which turn month numbers into month names. --- diff --git a/contrib/penfield/templatetags/__init__.py b/contrib/penfield/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/contrib/penfield/templatetags/penfield.py b/contrib/penfield/templatetags/penfield.py new file mode 100644 index 0000000..3f4c2f4 --- /dev/null +++ b/contrib/penfield/templatetags/penfield.py @@ -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)