django.contrib.humanize naturaday not working with USE_TZ = True

40 views
Skip to first unread message

James Zheng

unread,
May 12, 2012, 10:33:33 PM5/12/12
to django...@googlegroups.com
has anyone else run into the problem below?

I've converted all my datetime to tz aware, my default time zone in my setting file is 

TIME_ZONE = 'America/New_York'

in a template, I display the following,

{{ event.eventTime|naturalday:"D M d"|capfirst}}

the date right now in EST is 5/12, in UTC is 5/13. The example event date is 1:30pm EST 5/13. The template displays the time in EST, however, USE_TZ = True, naturalday displays "Today" instead of "Tomorrow. If I turn off USE_TZ, then it displays "Tomorrow". 


Looking at the code for humanize, it's just comparing the passed in value with date.today()

92 delta = value - date.today() 93 if delta.days == 0: 94 return _(u'today') 95 elif delta.days == 1: 96 return _(u'tomorrow')

and I believe my template is passing in the UTC datetime. Is there a way for me to change the date passed in to EST equivalent in the template?

Aymeric Augustin

unread,
Jun 22, 2012, 5:25:30 AM6/22/12
to django...@googlegroups.com
Le dimanche 13 mai 2012 04:33:33 UTC+2, James Zheng a écrit :
has anyone else run into the problem below?

Hi James,

Since you're talking about USE_TZ, I suppose you're using Django 1.4. But the code you're quoting no longer exists in that version:

That said, this appears to be a bug in Django. I've created a ticket:

Best regards,

-- 
Aymeric.
Reply all
Reply to author
Forward
0 new messages