Web IDE set current time

Posted on
  • Im using the Espruino web ide windows 10 download. Im trying to set the time on my puck using the "When sending code, set Espruino's clock to the current time" but its way off. The current time is 3/17 12:40 on my computer, the updated time to the puck says 3/30 5:40. So not only is it the wrong time zone, its two weeks ahead. This is my test code:

      var date = new Date().toString();
      print(date);
    

    Any ideas on how I could fix this would be appreciated.

  • Have a look in the console log of the ide...

    I'm seeing some stangeness too:

    Save on send transformed code to: E.setBootCode("setTime(1521267139.472);E­.setTimeZone(-780)\nModules.addCached
    

    The set TimeZone looks odd!

  • Thanks for letting me know!

    Looks like there's a unit mismatch - the timezone should be in hours, but the function that was used to get it in the web browser returned minutes. I've fixed this now but it won't be available until I do a new IDE release.

    In the mean time, adding E.setTimeZone(your_timezone) right at the top of your code should fix it.

  • Also - should the time zone and time get set for the save on send option? The next time the board resets and loads the code the time will be in the past - set to the time when the code was uploaded?

  • should the time zone and time get set for the save on send option?

    I think that is something that's also been improved in the most recent IDE builds - so the time only gets set at upload time (and doesn't get pushed into the 'save on send' stuff).

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Web IDE set current time

Posted by Avatar for Dan.js @Dan.js

Actions