prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Lost timeSince data for suggestions
  
  
  </issue>
  <code>
  [start of pootle/apps/pootle_misc/templatetags/locale.py]
  1 # -*- coding: utf-8 -*-
  2 #
  3 # Copyright (C) Pootle contributors.
  4 #
  5 # This file is a part of the Pootle project. It is distributed under the GPL3
  6 # or later license. See the LICENSE file for a copy of the license and the
  7 # AUTHORS file for copyright and authorship information.
  8 
  9 from django import template
  10 from django.utils.formats import get_format
  11 from django.utils.translation import trans_real
  12 
  13 from pootle.core.utils import dateformat
  14 
  15 
  16 register = template.Library()
  17 
  18 
  19 @register.simple_tag
  20 def locale_dir():
  21     """Returns current locale's direction."""
  22     return trans_real.get_language_bidi() and "rtl" or "ltr"
  23 
  24 
  25 @register.filter(name='dateformat')
  26 def do_dateformat(value, use_format='c'):
  27     """Formats a `value` date using `format`.
  28 
  29     :param value: a datetime object.
  30     :param use_format: a format string accepted by
  31         :func:`django.utils.formats.get_format` or
  32         :func:`django.utils.dateformat.format`. If none is set, the current
  33         locale's default format will be used.
  34     """
  35     try:
  36         use_format = get_format(use_format)
  37     except AttributeError:
  38         pass
  39 
  40     return dateformat.format(value, use_format)
  41 
  42 
  43 @register.simple_tag
  44 def locale_align():
  45     """Returns current locale's default alignment."""
  46     return trans_real.get_language_bidi() and "right" or "left"
  47
  [end of pootle/apps/pootle_misc/templatetags/locale.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/pootle/apps/pootle_misc/templatetags/locale.py b/pootle/apps/pootle_misc/templatetags/locale.py
  --- a/pootle/apps/pootle_misc/templatetags/locale.py
  +++ b/pootle/apps/pootle_misc/templatetags/locale.py
  @@ -6,11 +6,14 @@
   # or later license. See the LICENSE file for a copy of the license and the
   # AUTHORS file for copyright and authorship information.
   
  +import calendar
  +
   from django import template
   from django.utils.formats import get_format
   from django.utils.translation import trans_real
   
   from pootle.core.utils import dateformat
  +from pootle.local.dates import timesince
   
   
   register = template.Library()
  @@ -40,6 +43,11 @@
       return dateformat.format(value, use_format)
   
   
  +@register.filter(name='relative_datetime_format')
  +def do_relative_datetime_format(value):
  +    return timesince(calendar.timegm(value.timetuple()))
  +
  +
   @register.simple_tag
   def locale_align():
       """Returns current locale's default alignment."""
  
verification_info: {"golden_diff": "diff --git a/pootle/apps/pootle_misc/templatetags/locale.py b/pootle/apps/pootle_misc/templatetags/locale.py\n--- a/pootle/apps/pootle_misc/templatetags/locale.py\n+++ b/pootle/apps/pootle_misc/templatetags/locale.py\n@@ -6,11 +6,14 @@\n # or later license. See the LICENSE file for a copy of the license and the\n # AUTHORS file for copyright and authorship information.\n \n+import calendar\n+\n from django import template\n from django.utils.formats import get_format\n from django.utils.translation import trans_real\n \n from pootle.core.utils import dateformat\n+from pootle.local.dates import timesince\n \n \n register = template.Library()\n@@ -40,6 +43,11 @@\n     return dateformat.format(value, use_format)\n \n \n+@register.filter(name='relative_datetime_format')\n+def do_relative_datetime_format(value):\n+    return timesince(calendar.timegm(value.timetuple()))\n+\n+\n @register.simple_tag\n def locale_align():\n     \"\"\"Returns current locale's default alignment.\"\"\"\n", "issue": "Lost timeSince data for suggestions\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright (C) Pootle contributors.\n#\n# This file is a part of the Pootle project. It is distributed under the GPL3\n# or later license. See the LICENSE file for a copy of the license and the\n# AUTHORS file for copyright and authorship information.\n\nfrom django import template\nfrom django.utils.formats import get_format\nfrom django.utils.translation import trans_real\n\nfrom pootle.core.utils import dateformat\n\n\nregister = template.Library()\n\n\n@register.simple_tag\ndef locale_dir():\n    \"\"\"Returns current locale's direction.\"\"\"\n    return trans_real.get_language_bidi() and \"rtl\" or \"ltr\"\n\n\n@register.filter(name='dateformat')\ndef do_dateformat(value, use_format='c'):\n    \"\"\"Formats a `value` date using `format`.\n\n    :param value: a datetime object.\n    :param use_format: a format string accepted by\n        :func:`django.utils.formats.get_format` or\n        :func:`django.utils.dateformat.format`. If none is set, the current\n        locale's default format will be used.\n    \"\"\"\n    try:\n        use_format = get_format(use_format)\n    except AttributeError:\n        pass\n\n    return dateformat.format(value, use_format)\n\n\n@register.simple_tag\ndef locale_align():\n    \"\"\"Returns current locale's default alignment.\"\"\"\n    return trans_real.get_language_bidi() and \"right\" or \"left\"\n", "path": "pootle/apps/pootle_misc/templatetags/locale.py"}]}