OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) home.js – LOG TZ Fix request.

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #22643

    djagerif
    Participant

    I would like to request a small fix to both OS, OS2.0 and OSPi’s homepage.

    When displaying the homepage the current ‘Device Time’ correctly displays local time and timezone. When you scroll to the bottom of the page then the ‘Log:’ entry shows the last station run with the correct local time but it refers to it as UTC time. I think it should be UTC +- .

    In the home.js script I just hacked a proof of concept to see if it works. If someone could put together a more elegant solution it would be appreciated. I used OSPi as my example below:

    dstr=(new Date(lret*1000)).toUTCString().replace(" GMT","")+(((tz-48)>=0)?"+":"-")+(Math.abs(tz-48)/4>>0)+":"+((Math.abs(tz-48)%4)*15/10>>0)+((Math.abs(tz-48)%4)*15%10);

    Ingo

    #25555

    Ray
    Keymaster

    Cool, thanks for the suggestion. I’ve integrated your change to the 2.0 and 1.8.3 home.js scripts stored on rayshobby.net. Will update the files on GitHub next. One minor comment: I assume you have to take out the ‘.replace(” GMT”,””)’ part, otherwise it won’t print either ‘GMT’ or ‘UTC’. Or perhaps this is browser-dependent?

    #25556

    djagerif
    Participant

    Oops… Did I copy the wrong string??? Probably 🙂 The last bit should be right though.

    [Update] Nope, it’s right. I think the ‘replace’ statement might not be needed, perhaps Dan can comment as it’s his code initially.

    Ingo

    #25557

    Ray
    Keymaster

    Well, my original implementation uses this:
    dstr=(new Date(lret*1000)).toUTCString().replace(” GMT”,””);
    which prints out neither ‘GMT’ nor ‘UTC’. So I am actually a bit curious when you said it prints ‘UTC’. Perhaps the behavior is different on different browser. In any case, adding the time zone number is an improvement.

    #25558

    djagerif
    Participant

    Give it a test without that statement, it still prints UTC.

    Confirmed: Chrome prints GMT so now we know why the replace statement is there. IE prints UTC.

    #25559

    djagerif
    Participant

    Oh, just btw. I read somewhere that GMT is being phased out in favour of UTC. Look at the TZ Wiki, GMT starts at 12:00 noon and UTC more correctly starts at 00:00 midnight. They are interchangeable but UTC is more correct. (not my words, it’s from the Wiki)

    #25560

    Ray
    Keymaster

    I figured that it’s probably due to implementation differences in browsers. I tested both Chrome and Firefox and seem they both print ‘GMT’. I didn’t bother to test IE as I know the homepage doesn’t look pretty in IE and I am not a fan of IE 🙂

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) home.js – LOG TZ Fix request.