Added some automatic skips to autodocs. Added skeletal docs for contrib and complete...
[philo.git] / philo / contrib / penfield / templatetags / penfield.py
index 99e358c..7b9d946 100644 (file)
@@ -1,22 +1,46 @@
+"""
+Penfield supplies two template filters:
+
+.. templatefilter:: monthname
+
+monthname
+---------
+Returns the name of a month with the supplied numeric value.
+
+.. templatefilter:: apmonthname
+
+apmonthname
+-----------
+Returns the Associated Press abbreviated month name for the supplied numeric value.
+
+"""
 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:
+       try:
+               value = int(value)
+       except:
+               pass
+       
+       try:
+               return MONTHS[value]
+       except KeyError:
                return value
 
 register.filter('monthname', monthname)
 
 def apmonthname(value):
-       monthnum = int(value)
-       if 1 <= monthnum <= 12:
-               return MONTHS_AP[monthnum]
-       else:
+       try:
+               value = int(value)
+       except:
+               pass
+       
+       try:
+               return MONTHS_AP[value]
+       except KeyError:
                return value
 
 register.filter('apmonthname', apmonthname)