OpenSprinkler › Forums › Hardware Questions › OpenSprinkler Pi (OSPi) › home.js – LOG TZ Fix request.
- This topic is empty.
-
AuthorPosts
-
September 21, 2013 at 3:34 am #22643
djagerifParticipantI 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
September 22, 2013 at 9:10 am #25555
RayKeymasterCool, 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?
September 22, 2013 at 9:28 am #25556
djagerifParticipantOops… 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
September 22, 2013 at 9:32 am #25557
RayKeymasterWell, 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.September 22, 2013 at 10:29 am #25558
djagerifParticipantGive 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.
September 22, 2013 at 10:35 am #25559
djagerifParticipantOh, 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)
September 25, 2013 at 1:06 am #25560
RayKeymasterI 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 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.
OpenSprinkler › Forums › Hardware Questions › OpenSprinkler Pi (OSPi) › home.js – LOG TZ Fix request.