code: def format_year(year):
      
      if isinstance(year, (date, datetime)):
          # Django 1.5 and up, 'year' is a date object, consistent with month+day views.
          return unicode(year.year)
      else:
          # Django 1.4 just passes the kwarg as string.
          return unicode(year)
docs: Format the year value of the ``YearArchiveView``,
      which can be a integer or date object.
  
      This tag is no longer needed, but exists for template compatibility.
      It was a compatibility tag for Django 1.4.