Python Paste


timeinterval

timeinterval

Convert interval strings (in the form of 1w2d, etc) to seconds, and back again. Is not exactly about months or years (leap years in particular).

Accepts (y)ear, (b)month, (w)eek, (d)ay, (h)our, (m)inute, (s)econd.

Exports only time_encode and time_decode functions.


Functions

f time_encode(seconds) ...

Encodes a number of seconds (representing a time interval) into a form like 1h2d3s.

f time_decode(s) ...

Decodes a number in the format 1h4d3m (1 hour, 3 days, 3 minutes) into a number of seconds

See the source for more information.