Added some automatic skips to autodocs. Added skeletal docs for contrib and complete...
[philo.git] / philo / contrib / penfield / templatetags / penfield.py
1 """
2 Penfield supplies two template filters:
3
4 .. templatefilter:: monthname
5
6 monthname
7 ---------
8 Returns the name of a month with the supplied numeric value.
9
10 .. templatefilter:: apmonthname
11
12 apmonthname
13 -----------
14 Returns the Associated Press abbreviated month name for the supplied numeric value.
15
16 """
17 from django import template
18 from django.utils.dates import MONTHS, MONTHS_AP
19
20 register = template.Library()
21
22 def monthname(value):
23         try:
24                 value = int(value)
25         except:
26                 pass
27         
28         try:
29                 return MONTHS[value]
30         except KeyError:
31                 return value
32
33 register.filter('monthname', monthname)
34
35 def apmonthname(value):
36         try:
37                 value = int(value)
38         except:
39                 pass
40         
41         try:
42                 return MONTHS_AP[value]
43         except KeyError:
44                 return value
45
46 register.filter('apmonthname', apmonthname)