@register.filter
def naturalday(value, arg=None):
 try:
  tzinfo = getattr(value, 'tzinfo', None)
  value = date(value.year, value.month, value.day)
 except AttributeError:
  return value
 except ValueError:
  return value
 today = datetime.now(tzinfo).date()
 delta = (value - today)
 if (delta.days == 0):
  return _(u'today')
 elif (delta.days == 1):
  return _(u'tomorrow')
 elif (delta.days == (-1)):
  return _(u'yesterday')
 return defaultfilters.date(value, arg)

@ register . filter def naturalday ( value , arg = None ) : try : tzinfo = getattr ( value , 'tzinfo' , None ) value = date ( value . year , value . month , value . day ) except AttributeError : return value except ValueError : return value today = datetime . now ( tzinfo ) . date ( ) delta = ( value - today ) if ( delta . days == 0 ) : return _ ( u'today' ) elif ( delta . days == 1 ) : return _ ( u'tomorrow' ) elif ( delta . days == ( - 1 ) ) : return _ ( u'yesterday' ) return defaultfilters . date ( value , arg )
for date values that are tomorrow .