[关闭]
@aloyschen 2017-10-11T15:27:07.000000Z 字数 533 阅读 92

CodeWars 刷题总结

CodeWars


Human readable duration format

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:

  1. format_duration(62) # returns "1 minute and 2 seconds"
  2. format_duration(3662) # returns "1 hour, 1 minute and 2 seconds"

知识点

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注