Skip to content

Instantly share code, notes, and snippets.

@rssems
Created September 20, 2017 22:37
Show Gist options
  • Save rssems/f09e1a15f769d8172b676ea51cb7bb61 to your computer and use it in GitHub Desktop.
Save rssems/f09e1a15f769d8172b676ea51cb7bb61 to your computer and use it in GitHub Desktop.
origin = null
timer = null
time = ->
now = Date.now()
secs = Math.floor((now - origin) / 1000)
s = secs % 60
min = Math.floor(secs / 60)
if s < 10 then s = "0" + s
if min < 10 then min = "0" + min
textLayer.text = "#{min}:#{s}"
startTimer = ->
timer = setInterval(time, 1000)
origin = Date.now()
timer
stopTimer = ->
clearInterval(timer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment