From e94c607b3e5bb23cfa37a34f38a9e920ec6afe92 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 11 Dec 2013 17:27:42 +1300 Subject: [PATCH] documentation! --- plugins/util/timeformat.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugins/util/timeformat.py b/plugins/util/timeformat.py index 4661871..ebfe333 100644 --- a/plugins/util/timeformat.py +++ b/plugins/util/timeformat.py @@ -1,6 +1,23 @@ from util import text def format_time(seconds, count=3, accuracy=6, simple=False): + """ + Takes a length of time in seconds and returns a string describing that length of time. + This function has a number of optional arguments that can be combined: + + SIMPLE: displays the time in a simple format + >>> format_time(SECONDS) + 1 hour, 2 minutes, and 34 seconds + >>> format_time(SECONDS, simple=True) + 1h 2m 34s + + COUNT: how many periods should be shown (default 3) + >>> format_time(SECONDS) + 147 years, 9 months and 8 weeks + >>> format_time(SECONDS, count=6) + 147 years, 9 months, 7 weeks, 18 hours, 12 minutes and 34 seconds + """ + if simple: periods = [ ('c', 60 * 60 * 24 * 365 * 100),