Skip to content

Instantly share code, notes, and snippets.

@rafbm
Created December 10, 2012 23:41
Show Gist options
  • Save rafbm/4254381 to your computer and use it in GitHub Desktop.
Save rafbm/4254381 to your computer and use it in GitHub Desktop.
Little hack for using readable MM:SS time values in CoffeeScript
Number::m = (seconds = 0) ->
this * 60 + seconds
markers = [
0.m 36
1.m 14
1.m 48
2.m 23
2.m 56
3.m 30
4.m 7
]
# markers => [ 36, 74, 108, 143, 176, 210, 247 ]
// Generated by CoffeeScript 1.4.0
var markers;
Number.prototype.m = function(seconds) {
if (seconds == null) {
seconds = 0;
}
return this * 60 + seconds;
};
markers = [0..m(36), 1..m(14), 1..m(48), 2..m(23), 2..m(56), 3..m(30), 4..m(7)];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment