summaryrefslogtreecommitdiff
path: root/templates/project/widgets/clock/clock.coffee
blob: cd6b116386648fa022f5c12eb9b9e43bd9795178 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Dashing.Clock extends Dashing.Widget

  ready: ->
    setInterval(@startTime, 500)

  startTime: =>
    today = new Date()

    h = today.getHours()
    m = today.getMinutes()
    s = today.getSeconds()
    m = @formatTime(m)
    s = @formatTime(s)
    @set('time', h + ":" + m + ":" + s)
    @set('date', today.toDateString())

  formatTime: (i) ->
    if i < 10 then "0" + i else i