Your task in order to complete this Kata is to write a function which formats a duration, given as a number of seconds, in a human-friendly way.

The function must accept a non-negative integer. If it is zero, it just returns `"now"`. Otherwise,  the duration is expressed as a combination of `years`, `days`, `hours`, `minutes` and `seconds`.

It is much easier to understand with an example:

```Fortran
formatDuration (62)    // returns "1 minute and 2 seconds"
formatDuration (3662)  // returns "1 hour, 1 minute and 2 seconds"
```
```python
format_duration(62)    # returns "1 minute and 2 seconds"
format_duration(3662)  # returns "1 hour, 1 minute and 2 seconds"
```

**For the purpose of this Kata, a year is 365 days and a day is 24 hours.**

Note that spaces are important.

### Detailed rules

The resulting expression is made of components like `4 seconds`, `1 year`, etc.  In general, a positive integer and one of the valid units of time, separated by a space. The unit of time is used in plural if the integer is greater than 1.

The components are separated by a comma and a space (`", "`). Except the last component, which is separated by `" and "`, just like it would be written in English. 

A more significant units of time will occur before than a least significant one. Therefore, `1 second and 1 year` is not correct, but `1 year and 1 second` is.

Different components have different unit of times. So there is not repeated units like in `5 seconds and 1 second`.

A component will not appear at all if its value happens to be zero.  Hence, `1 minute and 0 seconds` is not valid, but it should be just `1 minute`.

 A unit of time must be used "as much as possible". It means that the function should not return `61 seconds`, but `1 minute and 1 second` instead.  Formally, the duration specified by  of a component must not be greater than any valid more significant unit of time.

Source: codewars | Difficulty: MEDIUM_HARD
Tags: String algorithms

Starter code: def format_duration(seconds):
	

Solutions:
times = [('year', 365 * 24 * 60 * 60), ('day', 24 * 60 * 60), ('hour', 60 * 60), ('minute', 60), ('second', 1)]

def format_duration(seconds):
	if not seconds:
		return 'now'
	chunks = []
	for (name, secs) in times:
		qty = seconds // secs
		if qty:
			if qty > 1:
				name += 's'
			chunks.append(str(qty) + ' ' + name)
		seconds = seconds % secs
	return ', '.join(chunks[:-1]) + ' and ' + chunks[-1] if len(chunks) > 1 else chunks[0]


def format_duration(seconds):
	if seconds == 0:
		return 'now'
	units = ((31536000, 'year'), (86400, 'day'), (3600, 'hour'), (60, 'minute'), (1, 'second'))
	(ts, t) = ([], seconds)
	for unit in units:
		(u, t) = divmod(t, unit[0])
		ts += ['{} {}{}'.format(u, unit[1], 's' if u > 1 else '')] if u != 0 else []
	return ', '.join([str(d) for d in ts[:-1]]) + (' and ' if len(ts) > 1 else '') + ts[-1]


def f(n, unit):
	return [', ', '{} {}{}'.format(n, unit, 's' if n > 1 else '')]

def format_duration(seconds):
	if not seconds:
		return 'now'
	(minutes, seconds) = divmod(seconds, 60)
	(hours, minutes) = divmod(minutes, 60)
	(days, hours) = divmod(hours, 24)
	(years, days) = divmod(days, 365)
	fs = []
	if years:
		fs.extend(f(years, 'year'))
	if days:
		fs.extend(f(days, 'day'))
	if hours:
		fs.extend(f(hours, 'hour'))
	if minutes:
		fs.extend(f(minutes, 'minute'))
	if seconds:
		fs.extend(f(seconds, 'second'))
	fs[-2] = ' and '
	fs.pop(0)
	return ''.join(fs)


def format_duration(seconds):
	if seconds == 0:
		return 'now'
	(minu, sec) = divmod(seconds, 60)
	(hour, minu) = divmod(minu, 60)
	(day, hour) = divmod(hour, 24)
	(year, day) = divmod(day, 365)
	if year == 0:
		if day == 0:
			if hour == 0:
				if minu == 0:
					if sec == 1:
						return str(sec) + ' second'
					return str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(minu) + ' minute'
					if sec == 1:
						return str(minu) + ' minute and ' + str(sec) + ' second'
					return str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(minu) + ' minutes'
					if sec == 1:
						return str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour == 1:
				if minu == 0:
					if sec == 0:
						return str(hour) + ' hour'
					if sec == 1:
						return str(hour) + ' hour and ' + str(sec) + ' second'
					return str(hour) + ' hour and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(hour) + ' hour, ' + str(minu) + ' minute'
					if sec == 1:
						return str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if sec == 0:
					return str(hour) + ' hour, ' + str(minu) + ' minutes'
				if sec == 1:
					return str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
				return str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour > 1:
				if minu == 0:
					if sec == 0:
						return str(hour) + ' hours'
					if sec == 1:
						return str(hour) + ' hours and ' + str(sec) + ' second'
					return str(hour) + ' hours and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(hour) + ' hours and ' + str(minu) + ' minute'
					if sec == 1:
						return str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(hour) + ' hours and ' + str(minu) + ' minutes'
					if sec == 1:
						return str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
		if day == 1:
			if hour == 0:
				if minu == 0:
					if sec == 0:
						return str(day) + ' day'
					if sec == 1:
						return str(day) + ' day and ' + str(sec) + ' second'
					return str(day) + ' day and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(day) + ' day and ' + str(minu) + ' minute'
					if sec == 1:
						return str(day) + ' day, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(day) + ' day, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(day) + ' day and ' + str(minu) + ' minutes'
					if sec == 1:
						return str(day) + ' day, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(day) + ' day, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour == 1:
				if minu == 0:
					if sec == 0:
						return str(day) + ' day and ' + str(hour) + ' hour and ' + str(sec)
					if sec == 1:
						return str(day) + ' day, ' + str(hour) + ' hour and ' + str(sec) + ' second'
					return str(day) + ' day, ' + str(hour) + ' hour and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minute'
					if sec == 1:
						return str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if sec == 0:
					return str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minutes'
				if sec == 1:
					return str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
				return str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour > 1:
				if minu == 0:
					if sec == 0:
						return str(day) + ' day and ' + str(hour) + ' hours'
					if sec == 1:
						return str(day) + ' day, ' + str(hour) + ' hours and ' + str(sec) + ' second'
					return str(day) + ' day, ' + str(hour) + ' hours and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(day) + ' day, ' + str(hour) + ' hours and ' + str(minu) + ' minute'
					if sec == 1:
						return str(day) + ' day, ' + str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(day) + ' day, ' + str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(day) + ' day, ' + str(hour) + ' hours and ' + str(minu) + ' minutes'
					if sec == 1:
						return str(day) + ' day, ' + str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(day) + ' day, ' + str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
		if day > 1:
			if hour == 0:
				if minu == 0:
					if sec == 0:
						return str(day) + ' days'
					if sec == 1:
						return str(day) + ' days and ' + str(sec) + ' second'
					return str(day) + ' days and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(day) + ' days and ' + str(minu) + ' minute'
					if sec == 1:
						return str(day) + ' days, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(day) + ' days, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(day) + ' days and ' + str(minu) + ' minutes'
					if sec == 1:
						return str(day) + ' days, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(day) + ' days, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour == 1:
				if minu == 0:
					if sec == 0:
						return str(day) + ' days and ' + str(hour) + ' hour and ' + str(sec)
					if sec == 1:
						return str(day) + ' days, ' + str(hour) + ' hour and ' + str(sec) + ' second'
					return str(day) + ' days, ' + str(hour) + ' hour and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(day) + ' days, ' + str(hour) + ' hour, ' + str(minu) + ' minute'
					if sec == 1:
						return str(day) + ' days, ' + str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(day) + ' days, ' + str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if sec == 0:
					return str(day) + ' days, ' + str(hour) + ' hours'
				if sec == 1:
					return str(day) + ' days, ' + str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
				return str(day) + ' days, ' + str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour > 1:
				if minu == 0:
					if sec == 0:
						return str(day) + ' days and ' + str(hour) + ' hours'
					if sec == 1:
						return str(day) + ' days, ' + str(hour) + ' hours and ' + str(sec) + ' second'
					return str(day) + ' days, ' + str(hour) + ' hours and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(day) + ' days, ' + str(hour) + ' hours and ' + str(minu) + ' minute'
					if sec == 1:
						return str(day) + ' days, ' + str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(day) + ' days, ' + str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(day) + ' days, ' + str(hour) + ' hours and ' + str(minu) + ' minutes'
					if sec == 1:
						return str(day) + ' days, ' + str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(day) + ' days, ' + str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
	if year == 1:
		if day == 0:
			if hour == 0:
				if minu == 0:
					if sec == 0:
						return str(year) + ' year'
					if sec == 1:
						return str(year) + ' year and ' + str(sec) + ' second'
					return str(year) + ' year and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' year and ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' year, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(year) + ' year and ' + str(minu) + ' minutes'
					if sec == 1:
						return str(year) + ' year, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour == 1:
				if minu == 0:
					if sec == 0:
						return str(year) + ' year and  ' + str(hour) + ' hour'
					if sec == 1:
						return str(year) + ' year, ' + str(hour) + ' hour and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(hour) + ' hour and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' year, ' + str(hour) + ' hour, ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' year, ' + str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if sec == 0:
					return str(year) + ' year, ' + str(hour) + ' hour, ' + str(minu) + ' minutes'
				if sec == 1:
					return str(year) + ' year, ' + str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
				return str(year) + ' year, ' + str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour > 1:
				if minu == 0:
					if sec == 0:
						return str(year) + ' year and ' + str(hour) + ' hours'
					if sec == 1:
						return str(year) + ' year, ' + str(hour) + ' hours and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(hour) + ' hours and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' year, ' + str(hour) + ' hours and ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' year, ' + str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(year) + ' year, ' + str(hour) + ' hours and ' + str(minu) + ' minutes'
					if sec == 1:
						return str(year) + ' year, ' + str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
		if day == 1:
			if hour == 0:
				if minu == 0:
					if sec == 0:
						return str(year) + ' year and  ' + str(day) + ' day'
					if sec == 1:
						return str(year) + ' year, ' + str(day) + ' day and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(day) + ' day and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' year, ' + str(day) + ' day and ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' year, ' + str(day) + ' day, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(day) + ' day, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(year) + ' year, ' + str(day) + ' day and ' + str(minu) + ' minutes'
					if sec == 1:
						return str(year) + ' year, ' + str(day) + ' day, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(day) + ' day, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour == 1:
				if minu == 0:
					if sec == 0:
						return str(year) + ' year, ' + str(day) + ' day and ' + str(hour) + ' hour and ' + str(sec)
					if sec == 1:
						return str(year) + ' year, ' + str(day) + ' day, ' + str(hour) + ' hour and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(day) + ' day, ' + str(hour) + ' hour and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' year, ' + str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' year, ' + str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if sec == 0:
					return str(year) + ' year, ' + str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minutes'
				if sec == 1:
					return str(year) + ' year, ' + str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
				return str(year) + ' year, ' + str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour > 1:
				if minu == 0:
					if sec == 0:
						return str(year) + ' year, ' + str(day) + ' day and ' + str(hour) + ' hours'
					if sec == 1:
						return str(year) + ' year, ' + str(day) + ' day, ' + str(hour) + ' hours and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(day) + ' day, ' + str(hour) + ' hours and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' year, ' + str(day) + ' day, ' + str(hour) + ' hours and ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' year, ' + str(day) + ' day, ' + str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(day) + ' day, ' + str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(year) + ' year, ' + str(day) + ' day, ' + str(day) + ' day, ' + str(hour) + ' hours and ' + str(minu) + ' minutes'
					if sec == 1:
						return str(year) + ' year, ' + str(day) + ' day, ' + str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(day) + ' day, ' + str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
		if day > 1:
			if hour == 0:
				if minu == 0:
					if sec == 0:
						return str(year) + ' year, and ' + str(day) + ' days'
					if sec == 1:
						return str(year) + ' year, ' + str(day) + ' days and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(day) + ' days and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' year, ' + str(day) + ' days and ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' year, ' + str(day) + ' days, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(day) + ' days, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(year) + ' year, ' + str(day) + ' days and ' + str(minu) + ' minutes'
					if sec == 1:
						return str(year) + ' year, ' + str(day) + ' days, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(day) + ' days, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour == 1:
				if minu == 0:
					if sec == 0:
						return str(year) + ' year, ' + str(day) + ' days and ' + str(hour) + ' hour and ' + str(sec)
					if sec == 1:
						return str(year) + ' year, ' + str(day) + ' days, ' + str(hour) + ' hour and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(day) + ' days, ' + str(hour) + ' hour and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' year, ' + str(day) + ' days, ' + str(hour) + ' hour, ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' year, ' + str(day) + ' days, ' + str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(day) + ' days, ' + str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if sec == 0:
					return str(year) + ' year, ' + str(day) + ' days, ' + str(hour) + ' hours'
				if sec == 1:
					return str(year) + ' year, ' + str(day) + ' days, ' + str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
				return str(year) + ' year, ' + str(day) + ' days, ' + str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour > 1:
				if minu == 0:
					if sec == 0:
						return str(year) + ' year, ' + str(day) + ' days and ' + str(hour) + ' hours'
					if sec == 1:
						return str(year) + ' year, ' + str(day) + ' days, ' + str(hour) + ' hours and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(day) + ' days, ' + str(hour) + ' hours and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' year, ' + str(day) + ' days, ' + str(hour) + ' hours and ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' year, ' + str(day) + ' days, ' + str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(day) + ' days, ' + str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(year) + ' year, ' + str(day) + ' days, ' + str(hour) + ' hours and ' + str(minu) + ' minutes'
					if sec == 1:
						return str(year) + ' year ' + str(day) + ' days, ' + str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(year) + ' year, ' + str(day) + ' days, ' + str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
	if year > 1:
		if day == 0:
			if hour == 0:
				if minu == 0:
					if sec == 0:
						return str(year) + ' years'
					if sec == 1:
						return str(year) + ' years and ' + str(sec) + ' second'
					return str(year) + ' years and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' years and ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' years, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(year) + ' years and ' + str(minu) + ' minutes'
					if sec == 1:
						return str(year) + ' years, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour == 1:
				if minu == 0:
					if sec == 0:
						return str(year) + ' years and  ' + str(hour) + ' hour'
					if sec == 1:
						return str(year) + ' years, ' + str(hour) + ' hour and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(hour) + ' hour and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' years, ' + str(hour) + ' hour, ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' years, ' + str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if sec == 0:
					return str(year) + ' years, ' + str(hour) + ' hour, ' + str(minu) + ' minutes'
				if sec == 1:
					return str(year) + ' years, ' + str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
				return str(year) + ' years, ' + str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour > 1:
				if minu == 0:
					if sec == 0:
						return str(year) + ' years and ' + str(hour) + ' hours'
					if sec == 1:
						return str(year) + ' years, ' + str(hour) + ' hours and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(hour) + ' hours and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' years, ' + str(hour) + ' hours and ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' years, ' + str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(year) + ' years, ' + str(hour) + ' hours and ' + str(minu) + ' minutes'
					if sec == 1:
						return str(year) + ' years, ' + str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
		if day == 1:
			if hour == 0:
				if minu == 0:
					if sec == 0:
						return str(year) + ' years and  ' + str(day) + ' day'
					if sec == 1:
						return str(year) + ' years, ' + str(day) + ' day and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(day) + ' day and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' years, ' + str(day) + ' day and ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' years, ' + str(day) + ' day, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(day) + ' day, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(year) + ' years, ' + str(day) + ' day and ' + str(minu) + ' minutes'
					if sec == 1:
						return str(year) + ' years, ' + str(day) + ' day, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(day) + ' day, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour == 1:
				if minu == 0:
					if sec == 0:
						return str(year) + ' years, ' + str(day) + ' day and ' + str(hour) + ' hour and ' + str(sec)
					if sec == 1:
						return str(year) + ' years, ' + str(day) + ' day, ' + str(hour) + ' hour and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(day) + ' day, ' + str(hour) + ' hour and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' years, ' + str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' years, ' + str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' yeas, ' + str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if sec == 0:
					return str(year) + ' years, ' + str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minutes'
				if sec == 1:
					return str(year) + ' years, ' + str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
				return str(year) + ' years, ' + str(day) + ' day, ' + str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour > 1:
				if minu == 0:
					if sec == 0:
						return str(year) + ' years, ' + str(day) + ' day and ' + str(hour) + ' hours'
					if sec == 1:
						return str(year) + ' years, ' + str(day) + ' day, ' + str(hour) + ' hours and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(day) + ' day, ' + str(hour) + ' hours and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' years, ' + str(day) + ' day, ' + str(hour) + ' hours and ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' years, ' + str(day) + ' day, ' + str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(day) + ' day, ' + str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(year) + ' years, ' + str(day) + ' day, ' + str(day) + ' day, ' + str(hour) + ' hours and ' + str(minu) + ' minutes'
					if sec == 1:
						return str(year) + ' years, ' + str(day) + ' day, ' + str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(day) + ' day, ' + str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
		if day > 1:
			if hour == 0:
				if minu == 0:
					if sec == 0:
						return str(year) + ' years, and ' + str(day) + ' days'
					if sec == 1:
						return str(year) + ' years, ' + str(day) + ' days and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(day) + ' days and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' years, ' + str(day) + ' days and ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' years, ' + str(day) + ' days, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(day) + ' days, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(year) + ' years, ' + str(day) + ' days and ' + str(minu) + ' minutes'
					if sec == 1:
						return str(year) + ' years, ' + str(day) + ' days, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(day) + ' days, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour == 1:
				if minu == 0:
					if sec == 0:
						return str(year) + ' years, ' + str(day) + ' days and ' + str(hour) + ' hour and ' + str(sec)
					if sec == 1:
						return str(year) + ' years, ' + str(day) + ' days, ' + str(hour) + ' hour and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(day) + ' days, ' + str(hour) + ' hour and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' years, ' + str(day) + ' days, ' + str(hour) + ' hour, ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' years, ' + str(day) + ' days, ' + str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(day) + ' days, ' + str(hour) + ' hour, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if sec == 0:
					return str(year) + ' years, ' + str(day) + ' days, ' + str(hour) + ' hours'
				if sec == 1:
					return str(year) + ' years, ' + str(day) + ' days, ' + str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
				return str(year) + ' years, ' + str(day) + ' days, ' + str(hour) + ' hour, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'
			if hour > 1:
				if minu == 0:
					if sec == 0:
						return str(year) + ' years, ' + str(day) + ' days and ' + str(hour) + ' hours'
					if sec == 1:
						return str(year) + ' years, ' + str(day) + ' days, ' + str(hour) + ' hours and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(day) + ' days, ' + str(hour) + ' hours and ' + str(sec) + ' seconds'
				if minu == 1:
					if sec == 0:
						return str(year) + ' years, ' + str(day) + ' days, ' + str(hour) + ' hours and ' + str(minu) + ' minute'
					if sec == 1:
						return str(year) + ' years, ' + str(day) + ' days, ' + str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(day) + ' days, ' + str(hour) + ' hours, ' + str(minu) + ' minute and ' + str(sec) + ' seconds'
				if minu > 1:
					if sec == 0:
						return str(year) + ' years, ' + str(day) + ' days, ' + str(hour) + ' hours and ' + str(minu) + ' minutes'
					if sec == 1:
						return str(year) + ' years, ' + str(day) + ' days, ' + str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' second'
					return str(year) + ' years, ' + str(day) + ' days, ' + str(hour) + ' hours, ' + str(minu) + ' minutes and ' + str(sec) + ' seconds'


def format_duration(s):
	dt = []
	for (b, w) in [(60, 'second'), (60, 'minute'), (24, 'hour'), (365, 'day'), (s + 1, 'year')]:
		(s, m) = divmod(s, b)
		if m:
			dt.append('%d %s%s' % (m, w, 's' * (m > 1)))
	return ' and '.join(', '.join(dt[::-1]).rsplit(', ', 1)) or 'now'