kyu_4.human_readable_duration_format package

Submodules

kyu_4.human_readable_duration_format.format_duration module

Format duration.

A function which formats a duration, given as a number of seconds, in a human-friendly way. Created by Egor Kostan. GitHub: https://github.com/ikostan

kyu_4.human_readable_duration_format.format_duration.calc_days(seconds: int) int[source]

Calculate days.

Parameters:

seconds – int

Returns:

int

kyu_4.human_readable_duration_format.format_duration.calc_hours(seconds: int) int[source]

Calculate hours.

Parameters:

seconds – int

Returns:

int

kyu_4.human_readable_duration_format.format_duration.calc_minutes(seconds: int) int[source]

Calculate minutes.

Parameters:

seconds – int

Returns:

int

kyu_4.human_readable_duration_format.format_duration.calc_seconds(seconds: int) int[source]

Calculate seconds.

Parameters:

seconds – int

Returns:

int

kyu_4.human_readable_duration_format.format_duration.calc_years(seconds: int) int[source]

Calculate years.

Parameters:

seconds – int

Returns:

int

kyu_4.human_readable_duration_format.format_duration.format_days(days: int, day: str, result: str) str[source]

Format days for the final string.

Parameters:
  • days – int

  • day – str

  • result – str

Returns:

str

kyu_4.human_readable_duration_format.format_duration.format_duration(seconds: int) str[source]

format_duration function.

A function which formats a duration, given as a number of seconds, in a human-friendly way. :param seconds: int :return: str

kyu_4.human_readable_duration_format.format_duration.format_hours(hours: int, hour: str, result: str) str[source]

Format hours for the final string.

Parameters:
  • hours – int

  • hour – str

  • result – str

Returns:

str

kyu_4.human_readable_duration_format.format_duration.format_minutes(minutes: int, seconds: int, minute: str, result: str) str[source]

Format minutes for the final string.

Parameters:
  • minutes – int

  • seconds – int

  • minute – str

  • result – str

Returns:

str

kyu_4.human_readable_duration_format.format_duration.format_seconds(seconds: int, second: str, result: str) str[source]

Format seconds for the final string.

Parameters:
  • seconds – int

  • second – str

  • result – str

Returns:

str

kyu_4.human_readable_duration_format.format_duration.get_string(number: int, string: str) str[source]

Concatenate string result.

Parameters:
  • number – int

  • string – str

Returns:

str

kyu_4.human_readable_duration_format.test_format_duration module

Test for ‘Human readable duration format’.

Created by Egor Kostan. GitHub: https://github.com/ikostan

class kyu_4.human_readable_duration_format.test_format_duration.FormatDurationTestCase(methodName='runTest')[source]

Bases: TestCase

Testing format_duration.

_classSetupFailed = False
_class_cleanups = []
test_format_duration = None
test_format_duration_00(**kw)

Test format_duration function [with seconds=1, expected=’1 second’].

Test 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. :return:

test_format_duration_01(**kw)

Test format_duration function [with seconds=62, expected=’1 minute and 2 seconds’].

Test 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. :return:

test_format_duration_02(**kw)

Test format_duration function [with seconds=120, expected=’2 minutes’].

Test 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. :return:

test_format_duration_03(**kw)

Test format_duration function [with seconds=3600, expected=’1 hour’].

Test 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. :return:

test_format_duration_04(**kw)

Test format_duration function [with seconds=3662, expected=’1 hour, 1 minute and 2 seconds’].

Test 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. :return:

test_format_duration_05(**kw)

Test format_duration function [with seconds=15731080, expected=’182 days, 1 hour, 44 minutes and 40 seconds’].

Test 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. :return:

test_format_duration_06(**kw)

Test format_duration function [with seconds=132030240, expected=’4 years, 68 days, 3 hours and 4 minutes’].

Test 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. :return:

test_format_duration_07(**kw)

Test format_duration function [with seconds=205851834, expected=’6 years, 192 days, 13 hours, 3 minutes and 54 seconds’].

Test 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. :return:

test_format_duration_08(**kw)

Test format_duration function [with seconds=253374061, expected=’8 years, 12 days, 13 hours, 41 minutes and 1 second’].

Test 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. :return:

test_format_duration_09(**kw)

Test format_duration function [with seconds=242062374, expected=’7 years, 246 days, 15 hours, 32 minutes and 54 seconds’].

Test 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. :return:

test_format_duration_10(**kw)

Test format_duration function [with seconds=101956166, expected=’3 years, 85 days, 1 hour, 9 minutes and 26 seconds’].

Test 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. :return:

test_format_duration_11(**kw)

Test format_duration function [with seconds=33243586, expected=’1 year, 19 days, 18 hours, 19 minutes and 46 seconds’].

Test 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. :return:

test_format_duration_12(**kw)

Test format_duration function [with seconds=9041160, expected=’104 days, 15 hours and 26 minutes’].

Test 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. :return:

Module contents

Human readable duration format package.