Created
June 5, 2012 19:12
-
-
Save khamidou/2877088 to your computer and use it in GitHub Desktop.
An example filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import template | |
from django.contrib.sites.models import Site | |
from urlparse import urlparse | |
import datetime | |
register = template.Library() | |
@register.filter(name='dayinweek', is_safe=True, expects_localtime=True) | |
def dayincurrentweek(day): | |
if day == datetime.date.today(): | |
return "Today" | |
min_date = datetime.date.today() - datetime.timedelta(7) | |
if day > min_date and day < datetime.date.today(): | |
return day.strftime("Last %A") | |
else: | |
return day.strftime("%B, %d") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment