Ticket #11321: 11321-r11173.diff

File 11321-r11173.diff, 1.2 KB (added by Sergio Oliveira, 15 years ago)

Patch including some fixes (using svn diff)

  • django/contrib/humanize/templatetags/humanize.py

     
    22from django.utils.encoding import force_unicode
    33from django import template
    44from django.template import defaultfilters
    5 from datetime import date
     5from datetime import date, datetime
    66import re
    77
    88register = template.Library()
     
    8080    present day returns representing string. Otherwise, returns a string
    8181    formatted according to settings.DATE_FORMAT.
    8282    """
    83     try:
     83    try:
     84        tzinfo = getattr(value, 'tzinfo', None)
    8485        value = date(value.year, value.month, value.day)
    8586    except AttributeError:
    8687        # Passed value wasn't a date object
     
    8889    except ValueError:
    8990        # Date arguments out of range
    9091        return value
    91     delta = value - date.today()
     92    delta = value - datetime.now(tzinfo).\
     93                    replace(microsecond=0, second=0, minute=0, hour=0).date()
    9294    if delta.days == 0:
    9395        return _(u'today')
    9496    elif delta.days == 1:
Back to Top