Permalink
Browse files

add time sugar to Number

  • Loading branch information...
1 parent c575b3e commit ae99fb2bacebf876f5635c11639d820b4336803f @erisdev committed Mar 23, 2012
Showing with 7 additions and 1 deletion.
  1. +7 −1 scripts/utilities.coffee
View
@@ -19,6 +19,12 @@ Number::toPaddedString = (length, base = 10) ->
string = "0#{string}" while string.length < length
string
+Number::nanoseconds = -> this / 1000000
+Number::milliseconds = -> this
+Number::seconds = -> this * 1000
+Number::minutes = -> this * 60000
+Number::hours = -> this * 3600000
+
RegExp.escape = (string) ->
string.replace /[\/\.\*\+\?\|\(\)\[\]\{\}\\]/g, '\\$&'
@@ -62,5 +68,5 @@ hideProperties = (obj, properties...) ->
Object.defineProperty obj, prop, enumerable: false
hideProperties Object.prototype, 'tap', 'isEmpty', 'getKeys', 'getOwnKeys'
-hideProperties Number.prototype, 'toPaddedString'
+hideProperties Number.prototype, 'toPaddedString', 'nanoseconds', 'milliseconds', 'seconds', 'minutes', 'hours'
hideProperties String.prototype, 'template', 'escapeEntities', 'unescapeEntities'

0 comments on commit ae99fb2

Please sign in to comment.