Look at the timesince filter in django's source for an example, as it
does almost exactly what you're looking for.

On Dec 23, 8:53 am, Alfonso <allanhender...@gmail.com> wrote:
> Hi,
>
> Trying to implement a very simple template tag that will output a
> company's age.  So idea being if company was established in 1860 then
> it should output '148 years old' if my math is right ;-)
>
> this is what I've got:
>
> from django.template import *
>
> register = Library()
>
> @register.filter
> def age(comp_age):
>     d = datetime.date.today()
>     b = 1860
>     comp_age = int(d.year - b)
>     return comp_age
>
> No joy -  any ideas, must be pretty simple !?
>
> Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to