1. Sergey Maranchuk
  2. DjangoBB

Commits

Andrei Kavaleu  committed 14ec811

#74 forum_time tag and Reputation.__unicode__ print local time

  • Participants
  • Parent commits d4ad775
  • Branches default

Comments (0)

Files changed (2)

File djangobb_forum/models.py

View file
         unique_together = (('from_user', 'post'),)
 
     def __unicode__(self):
-        return u'T[%d], FU[%d], TU[%d]: %s' % (self.post.id, self.from_user.id, self.to_user.id, unicode(self.time))
+        time = timezone.localtime(self.time)
+        return u'T[%d], FU[%d], TU[%d]: %s' % (self.post.id, self.from_user.id, self.to_user.id, unicode(time))
 
 
 class ProfileManager(models.Manager):

File djangobb_forum/templatetags/forum_extras.py

View file
 from django.db import settings
 from django.utils.html import escape
 from django.utils.hashcompat import md5_constructor
+from django.utils import timezone
 from django.contrib.humanize.templatetags.humanize import naturalday
 
 from pagination.templatetags.pagination_tags import paginate
         self.time = template.Variable(time)
 
     def render(self, context):
-        time = self.time.resolve(context)
-        formated_time = u'%s %s' % (naturalday(time), time.strftime('%H:%M:%S'))
-        formated_time = mark_safe(formated_time)
-        return formated_time
+        time = timezone.localtime(self.time.resolve(context))
+        formatted_time = u'%s %s' % (naturalday(time), time.strftime('%H:%M:%S'))
+        formatted_time = mark_safe(formatted_time)
+        return formatted_time
 
 
 # TODO: this old code requires refactoring