diff options
author | mathieui <mathieui@mathieui.net> | 2011-11-18 23:34:38 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2011-11-18 23:34:38 +0100 |
commit | 6ef488ae803381e4059e609e8d99e766cfe32675 (patch) | |
tree | d184106b0995cf9219cbc17c4c1b81ebd72fd696 /src | |
parent | c83cdb6b4a84cce07ebf6f11f5fc41561b265f99 (diff) | |
download | poezio-6ef488ae803381e4059e609e8d99e766cfe32675.tar.gz poezio-6ef488ae803381e4059e609e8d99e766cfe32675.tar.bz2 poezio-6ef488ae803381e4059e609e8d99e766cfe32675.tar.xz poezio-6ef488ae803381e4059e609e8d99e766cfe32675.zip |
Add some __doc__ to the parse from/to str/secs methods
Diffstat (limited to 'src')
-rw-r--r-- | src/common.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/common.py b/src/common.py index fdad77a9..a30c344f 100644 --- a/src/common.py +++ b/src/common.py @@ -194,6 +194,11 @@ def replace_key_with_bound(key): return key def parse_str_to_secs(duration=''): + """ + Parse a string of with a number of d, h, m, s + >>> parse_str_to_secs("1d3m1h") + 90180 + """ values = {'s': 1, 'm': 60, 'h': 3600, 'd': 86400} result = 0 tmp = '0' @@ -211,6 +216,12 @@ def parse_str_to_secs(duration=''): return result def parse_secs_to_str(duration=0): + """ + Parse a number of seconds to a human-readable string. + The string has the form XdXhXmXs. 0 units are removed. + >>> parse_secs_to_str(3601) + 1h1s + """ secs, mins, hours, days = 0, 0, 0, 0 result = '' secs = duration % 60 |