1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | from datetime import datetime,time
from django.utils.dateformat import DateFormat
register = Library()
@register.filter
def humantime(t):
now = datetime.now()
if datetime.combine(now, time()) < t and t < datetime.combine(now + timedelta(1), time()):
f = 'g:i a'
elif now.year == t.year:
f = 'M j'
else:
f = 'n/j/y'
df = DateFormat(t)
return df.format(f).replace('.m.', 'm')
|
More like this
- datemate by catellar 1 year, 9 months ago
- Coalesce for F() by axil 1 year, 3 months ago
- Take a django.core.mail email message and replace any MEDIA_URL-served images with attached images by agrossman@gmail.com 1 year, 4 months ago
- Confirm alert if the user navigates away without saving changes by mrazzari 3 years, 10 months ago
- Django Registration with GMail account by btbytes 6 years, 1 month ago
Comments