prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Ajouter les unités temporelles sur les graphs des stats
  Cete amélioration est demandée par un auteur :  
  
  >  Ce serait bien, aussi, de mettre les unités à côté du temps. Parce que là, j’ai 03:51, mais je ne sais pas si c’est min:sec ou sec:mil
  
  </issue>
  <code>
  [start of zds/utils/templatetags/seconds_to_duration.py]
  1 from django import template
  2 import datetime
  3 
  4 register = template.Library()
  5 
  6 
  7 # TODO add unit test
  8 @register.filter('seconds_to_duration')
  9 def seconds_to_duration(value):
  10     """
  11     Display a human-readable reading-time (or any other duration)
  12     from a duration in seconds.
  13     """
  14     if value <= 0:
  15         return ''
  16 
  17     duration = datetime.timedelta(seconds=value)
  18     return str(duration)
  19
  [end of zds/utils/templatetags/seconds_to_duration.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/zds/utils/templatetags/seconds_to_duration.py b/zds/utils/templatetags/seconds_to_duration.py
  --- a/zds/utils/templatetags/seconds_to_duration.py
  +++ b/zds/utils/templatetags/seconds_to_duration.py
  @@ -4,6 +4,14 @@
   register = template.Library()
   
   
  +# https://stackoverflow.com/a/8907269/2226755
  +def strfdelta(tdelta, fmt):
  +    d = {'days': tdelta.days}
  +    d['hours'], rem = divmod(tdelta.seconds, 3600)
  +    d['minutes'], d['seconds'] = divmod(rem, 60)
  +    return fmt.format(**d)
  +
  +
   # TODO add unit test
   @register.filter('seconds_to_duration')
   def seconds_to_duration(value):
  @@ -15,4 +23,7 @@
           return ''
   
       duration = datetime.timedelta(seconds=value)
  -    return str(duration)
  +    if duration < 3600
  +        return strfdelta(duration, '{minutes}m{seconds}s')
  +    else
  +        return strfdelta(duration, '{hours}h{minutes}m{seconds}s')
  
verification_info: {"golden_diff": "diff --git a/zds/utils/templatetags/seconds_to_duration.py b/zds/utils/templatetags/seconds_to_duration.py\n--- a/zds/utils/templatetags/seconds_to_duration.py\n+++ b/zds/utils/templatetags/seconds_to_duration.py\n@@ -4,6 +4,14 @@\n register = template.Library()\n \n \n+# https://stackoverflow.com/a/8907269/2226755\n+def strfdelta(tdelta, fmt):\n+    d = {'days': tdelta.days}\n+    d['hours'], rem = divmod(tdelta.seconds, 3600)\n+    d['minutes'], d['seconds'] = divmod(rem, 60)\n+    return fmt.format(**d)\n+\n+\n # TODO add unit test\n @register.filter('seconds_to_duration')\n def seconds_to_duration(value):\n@@ -15,4 +23,7 @@\n         return ''\n \n     duration = datetime.timedelta(seconds=value)\n-    return str(duration)\n+    if duration < 3600\n+        return strfdelta(duration, '{minutes}m{seconds}s')\n+    else\n+        return strfdelta(duration, '{hours}h{minutes}m{seconds}s')\n", "issue": "Ajouter les unit\u00e9s temporelles sur les graphs des stats\nCete am\u00e9lioration est demand\u00e9e par un auteur :  \r\n\r\n>  Ce serait bien, aussi, de mettre les unit\u00e9s \u00e0 c\u00f4t\u00e9 du temps. Parce que l\u00e0, j\u2019ai 03:51, mais je ne sais pas si c\u2019est min:sec ou sec:mil\n", "before_files": [{"content": "from django import template\nimport datetime\n\nregister = template.Library()\n\n\n# TODO add unit test\n@register.filter('seconds_to_duration')\ndef seconds_to_duration(value):\n    \"\"\"\n    Display a human-readable reading-time (or any other duration)\n    from a duration in seconds.\n    \"\"\"\n    if value <= 0:\n        return ''\n\n    duration = datetime.timedelta(seconds=value)\n    return str(duration)\n", "path": "zds/utils/templatetags/seconds_to_duration.py"}]}