def humanize_time(duration, fmt_short=True):
  """Convert duration in seconds to a friendly human readable form.

  Args:
    duration: int.
      Duration in seconds.
    fmt_short: bool, optional.
      Display output in short/long format.

  Returns:
    str. Human-friendly durations.

  #### Examples

  ```python
  humanize_time(3662)
  ## '1h 1m 2s'

  humanize_time(3662, fmt_short=False)
  ## '1 hour, 1 minute, 2 seconds'
  ```
  """
  duration = int(duration)
  if duration == 0:
    return "0s" if fmt_short else "0 seconds"

  intervals = [1, 60, 3600, 86400, 604800, 2419200, 29030400]
  if fmt_short:
    names = ['s' * 2, 'm' * 2, 'h' * 2, 'd' * 2, 'w' * 2, 'y' * 2]
  else:
    names = [('second', 'seconds'),
             ('minute', 'minutes'),
             ('hour', 'hours'),
             ('day', 'days'),
             ('week', 'weeks'),
             ('month', 'months'),
             ('year', 'years')]

  result = []

  for i in range(len(names) - 1, -1, -1):
    a = duration // intervals[i]
    if a > 0:
      result.append((a, names[i][1 % a]))
      duration -= a * intervals[i]

  if fmt_short:
    return " ".join(["%s%s" % x for x in result])
  return ", ".join(["%s %s" % x for x in result])