0

I'm trying to make a dashboard for work with Smashing (used to be called Dashing), it runs on a Raspberry Pi 3B.

I am new to coffeescript. I'm trying to make an open sign, It should: Check the day and the hours and if it is tuesday, wednesday or friday between 9am and 5pm it should print "We are opened, come in" and if it's outside those hours it should say something like "We are closed, please come again" the open text should also be applied on thursday between 9am and 1pm and the rest of the time it should say closed.

Here is the code I was trying to edit and change from the clock widget:

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())

###
  openTime: ->
 if h > 8 and < 6 then @set('openclosed', "Wij zijn open, kom gezellig binnen!") else @set('openclosed', "Wij zijn gesloten, kom gauw weer terug!")
###
 
  formatTime: (i) ->
    if i < 10 then "0" + i else i
 

The commented out part is what I added, obviously to experienced people it's not working..

Thanks in advance! Greetings, Thursten

BillRay
  • 51
  • 5
  • What happens if you call the opentime method from starttime? From the code you've shown, starttime is the only method that is actually called (it's called on a loop via setInterval) – max pleaner Jun 08 '17 at 19:58
  • Where does the starttime come from than? I'm sorry I'm practically a noob.. 0=) – BillRay Jun 09 '17 at 07:49
  • your class defines a few methods, starttime and opentime being two of them. In `ready` (presumably called from elsewhere, but the invocation of which is not actually evident from the question), `setInterval(@startTime, 500)` basically calls starttime on a loop. _You never call endTime, though_ – max pleaner Jun 09 '17 at 08:13

0 Answers0