Skip to content

Instantly share code, notes, and snippets.

View kelkes's full-sized avatar

David Wippel kelkes

View GitHub Profile
@johanbrook
johanbrook / parseTimestamp.js
Last active August 29, 2015 14:06
Parse a timestamp or duration like `3h2m1s` to total seconds.
/*
* Parses a human readable duration on the form
* and return the total duration in seconds.
*
* @param {string} - Timestamp on the form XhYmZs. Unit
* parts are optional: 3h2s, 3m1s, 4h2m
* are all valid.
*/
function parseTimestamp(timestamp) {