Skip to content

Instantly share code, notes, and snippets.

@jillesme
Last active February 19, 2016 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jillesme/f38f29bb0062802a91b1 to your computer and use it in GitHub Desktop.
Save jillesme/f38f29bb0062802a91b1 to your computer and use it in GitHub Desktop.
Egghead total duration of a course..
(function (s) {
return [~~(s / 3600), ~~((s % 3600) / 60), s % 60].map(v => v < 10 ? '0' + v : v).join(':');
})([].slice.call(document.querySelectorAll('.duration'))
.filter((e, i, a) => ++i <= (a.length / 3))
.map(h => {
var t = h.textContent.match(/[0-9]{1,2}:[0-9]{1,2}/);
var p = t[0].split(':').map(Number);
return (p[0] * 60) + p[1]
}).reduce((p, c) => p + c, 0));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment