Author Topic: Odd Issue on Website  (Read 2955 times)

0 Members and 1 Guest are viewing this topic.

Offline HamiltonNJWeather

  • Contributor
  • ***
  • Posts: 104
    • HamiltonWeather.Net
Odd Issue on Website
« on: April 27, 2016, 09:57:39 PM »
I had an odd issue that just started happening on my site.  The time in my header is exactly 3 hours different than the time in my realtime display in the main ajax window. It is also different on all my sub pages, but is updating with the correct data.  Any ideas?!?!

www.hamiltonweather.net
John


Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: Odd Issue on Website
« Reply #1 on: April 27, 2016, 11:05:06 PM »
I had an odd issue that just started happening on my site.  The time in my header is exactly 3 hours different than the time in my realtime display in the main ajax window. It is also different on all my sub pages, but is updating with the correct data.  Any ideas?!?!

www.hamiltonweather.net


Try changing the time zone within the ajax-gizmo.php file.


Code: [Select]
$WDdateMDY = true;     // true=dates by WD are 'month/day/year'
//                     // false=dates by WD are 'day/month/year'
  $ourTZ = "America/Denver";  //NOTE: this *MUST* be set correctly to
// translate UTC times to your LOCAL time for the displays.




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline HamiltonNJWeather

  • Contributor
  • ***
  • Posts: 104
    • HamiltonWeather.Net
Re: Odd Issue on Website
« Reply #2 on: April 28, 2016, 06:25:26 AM »
I thought that was overridden by settings.php  - I never changed that, either. But I will give it a shot now. Thanks!


Sent from my iPhone using Tapatalk
John


Offline HamiltonNJWeather

  • Contributor
  • ***
  • Posts: 104
    • HamiltonWeather.Net
Re: Odd Issue on Website
« Reply #3 on: April 28, 2016, 06:29:54 AM »
Just tried it, it didn't switch .


Sent from my iPhone using Tapatalk
John


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Odd Issue on Website
« Reply #4 on: April 28, 2016, 11:18:39 AM »
Hmmm... without JavaScript, both the gizmo and the dashboard show the same time (from VWStags.php).

With JavaScript enabled, the gizmo is -3 hours from what the dashboard says (as you have observed).

The ajaxVWSwx.js script has
Code: [Select]
    var wflash = x.responseText.split(',');
  // now make sure we got the entire wflash.txt  -- thanks to Johnnywx
  // valid wflash.txt has 'F=nnnnnnnnnn'
  var wdpattern=/F\=(\d+)/;
  if( wdpattern.test(wflash[0]) &&
    ( updates <= maxupdates || maxupdates > 0  )) { // got it.. process wflash.txt
    if (maxupdates > 0 ) {updates++; } // increment counter if needed
        // main routine ---
    var datestamp = wflash[0]; // extracted from the F=() in the first string
    // Note: F=nnnnn: the value is number of seconds since Jan 01, 1900 00:00:00 UTC
    datestamp = datestamp.replace(/^I=\S+\&/i,"");     // remove I= field if present
    datestamp = datestamp.replace(wdpattern,"$1");     // extract timestamp from F=nnnnnnnn field
    var datezero = new Date('Jan 01, 1900 00:00:00 UTC');
    var datetime = new Date();
    datetime.setTime(datestamp*1000 + datezero.getTime()); // adjust date to offset from zero time
    set_ajax_obs("ajaxdatetime",datetime);
    set_ajax_obs("ajaxdatetimelocale",datetime.toLocaleString());
    set_ajax_obs("ajaxdate",datetime.toLocaleDateString());
    set_ajax_obs("ajaxtime",datetime.toLocaleTimeString());
    set_ajax_obs("gizmodate",datetime.toLocaleDateString());
    set_ajax_obs("gizmotime",datetime.toLocaleTimeString());
to process the (somewhat funky) timestamp from the wflash.txt.   

ajax-gizmo.php has
Code: [Select]
<span class="ajax" id="gizmodate"><?php echo $UpdateDate;?></span>&nbsp;
<span class="ajax" id="gizmotime"></span>
to display the date, time.

ajax-dashboard.php has
Code: [Select]
    <span class="ajax" id="ajaxindicator"><?php langtrans('Updated'); ?>:</span>&nbsp;@
    <span class="ajax" id="ajaxdate">
    <?php echo fixup_date($date) . ' ' fixup_time($time);
  if(isset($timeofnextupdate)) { echo " - " langtransstr('next update at') . " " fixup_time($timeofnextupdate);} ?>

    </span>&nbsp;<span class="ajax" id="ajaxtime"></span>

Since the ajaxVWSwx.js sets both ajaxdate/gizmodate and ajaxtime/gizmotime IDs using the same logic, they should appear as the same values when the script runs (or so one would think).

Watching the execution with Firefox FireBug shows in the gizmo area
Quote
<span id="gizmodate" class="ajax" lastobs="4/28/16" style="color: rgb(0, 204, 0);">4/28/16</span>
<span id="gizmotime" class="ajax" lastobs="8:08:40 AM" style="color: rgb(0, 204, 0);">8:08:40 AM</span>
while in the dashboard area it shows
Quote
<span id="ajaxindicator" class="ajax" style="color: rgb(0, 204, 0);">Updated:</span>
 @
<span id="ajaxdate" class="ajax" lastobs="4/28/16" style="color: rgb(0, 204, 0);">4/28/16</span>
<span id="ajaxtime" class="ajax" lastobs="11:08:40am" style="color: rgb(0, 204, 0);">11:08:40am</span>
  so... how did gizmotime get 3 hours behind ajaxtime when they come from the same code
Code: [Select]
    set_ajax_obs("ajaxtime",datetime.toLocaleTimeString());
set_ajax_obs("gizmotime",datetime.toLocaleTimeString());

I looked through all the JavaScripts loaded by the page, and can't find any other part that uses 'datetime' variable, or tries to replace 'gizmotime'.

I'll keep looking though... it is a puzzle.

Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Odd Issue on Website
« Reply #5 on: April 28, 2016, 11:41:00 AM »
Strange, the gizmo time at the top shows local time, for me it is +8 from the Ajax dashboard and corresponds to the local time here

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Odd Issue on Website
« Reply #6 on: April 28, 2016, 11:46:25 AM »
For the ajax dashboard I see:

Date and time corresponding to your station location, date is in my local format, time is not, it shows "am", which we do not use

header:
Date and time corresponding to my location in my format both (currently showing 28.4.2016 and time as 17:46)

Offline HamiltonNJWeather

  • Contributor
  • ***
  • Posts: 104
    • HamiltonWeather.Net
Re: Odd Issue on Website
« Reply #7 on: April 28, 2016, 12:21:03 PM »
I went through it this morning and couldn't find the answer either. Gonna check again after work. Could it be something in the VWS wxflash ? Just reaching, perhaps.


Sent from my iPhone using Tapatalk
John


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Odd Issue on Website
« Reply #8 on: April 28, 2016, 12:32:21 PM »
Hmmm... I tried it with Firefox, Chrome and Opera -- all did the same (-3 hr on gizmo AJAX update).
My test site using VWS doesn't show the issue (using the same ajaxVWSwx.js code).

Still looking for a cause...
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Odd Issue on Website
« Reply #9 on: April 28, 2016, 12:34:52 PM »
One other strange thing Ken,
I dont know the script very well, but there are two SPAN elements, one "date" and one "time", but looking at the output, the "time" remains empty and the "date" shows both date and time.

Also, when first loaded, it shows me both dates and times in the US format, then after first update, the dashboard switches to station date and time, both being in the US format. The header switches to date and time corresponding to my date and time and my date and time format

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Odd Issue on Website
« Reply #10 on: April 28, 2016, 01:19:50 PM »
Hi Jachym,

The set_ajax_obs() JavaScript function is common to all the ajax..wx.js scripts and serves to replace the inner HTML in the <span class="ajax" id="ajax....">...</span> parts of the markup (if the id= exists on the page).  It also adds a lastobs="..." with the last value of the inner HTML updated on the page.  That's used to do a 'green flash' on values that change with the next update.

The page is showing
Watching the execution with Firefox FireBug shows in the gizmo area
Quote
<span id="gizmodate" class="ajax" lastobs="4/28/16" style="color: rgb(0, 204, 0);">4/28/16</span>
<span id="gizmotime" class="ajax" lastobs="8:08:40 AM" style="color: rgb(0, 204, 0);">8:08:40 AM</span>
while in the dashboard area it shows
Quote
<span id="ajaxindicator" class="ajax" style="color: rgb(0, 204, 0);">Updated:</span>
 @
<span id="ajaxdate" class="ajax" lastobs="4/28/16" style="color: rgb(0, 204, 0);">4/28/16</span>
<span id="ajaxtime" class="ajax" lastobs="11:08:40am" style="color: rgb(0, 204, 0);">11:08:40am</span>
on execution of the AJAX script, so the PHP contents are replaced en mass with the new inner HTML in the span.  The initial values via PHP do use date+time in the datetime area, and null in the time area, but as you see, that is replaced with just date in the date area and a time in the time area by the AJAX update.

What I don't understand is why this identical code
Code: [Select]
set_ajax_obs("ajaxtime",datetime.toLocaleTimeString());
set_ajax_obs("gizmotime",datetime.toLocaleTimeString());
comes up with two different values being set from the same source of datetime.toLocalTimeString() ... that's the puzzle   #-o  ](*,)
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Odd Issue on Website
« Reply #11 on: April 28, 2016, 01:25:44 PM »
Yes, I see the same thing, the time at the top simply converts to my local time and local format, the dashboard shows his station time with "PM", while the header shows "19:25" - my current local time

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Odd Issue on Website
« Reply #12 on: April 28, 2016, 01:32:03 PM »
Ken something is probably wrong in general:

http://frankfortweather.us/

I see the same thing, top time shows my local, dashboard shows station time in US format

Offline cospringswx

  • Forecaster
  • *****
  • Posts: 4136
    • Colorado Springs Weather
Re: Odd Issue on Website
« Reply #13 on: April 28, 2016, 01:54:41 PM »
Mine is working fine in MST.




Ryan 

Colorado Springs, CO
www.cospringsweather.com
Davis Vantage Vue
Weather Display Software
Amcrest HD IP Camera

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Odd Issue on Website
« Reply #14 on: April 28, 2016, 02:05:16 PM »
Yes but you are using the WD script, the problem seems to be in:

ajaxVWSwx.js

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Odd Issue on Website
« Reply #15 on: April 28, 2016, 02:06:23 PM »
Mine is working fine in MST.
Ahh... but you're running Weather-Display and ajaxWDwx.js, not VWS and ajaxVWSwxf.js :)
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Odd Issue on Website
« Reply #16 on: April 28, 2016, 02:10:05 PM »
Ken do you have some links to other people using VWS and your template? I only found those two and both are showing wrong numbers

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Odd Issue on Website
« Reply #17 on: April 28, 2016, 02:17:16 PM »
OK, so it is confirmed, there is a problem, this one is also wrong:

http://www.madeliasliveweather.com/thompsonfarms/

this too:
http://www.carsonvalleyweather.com/wxindex.php

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Odd Issue on Website
« Reply #18 on: April 28, 2016, 02:23:02 PM »
I don´t understand this line:

    set_ajax_obs("ajaxdatetime",datetime);
    set_ajax_obs("ajaxdatetimelocale",datetime.toLocaleString());
    set_ajax_obs("ajaxdate",datetime.toLocaleDateString());
    set_ajax_obs("ajaxtime",datetime.toLocaleTimeString());
    set_ajax_obs("gizmodate",datetime.toLocaleDateString());
    set_ajax_obs("gizmotime",datetime.toLocaleTimeString());

All other scripts seem to have:

set_ajax_obs("ajaxdatetime",ajaxdateformat + " " +ajaxtimeformat);
« Last Edit: April 28, 2016, 02:24:41 PM by Jachym »

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Odd Issue on Website
« Reply #19 on: April 28, 2016, 02:53:51 PM »
Ken do you have some links to other people using VWS and your template? I only found those two and both are showing wrong numbers

Sure:

http://peotoneweather.com/ (showing same symptom-Virtual Weather Station (V15.00))
http://www.madeliasliveweather.com/thompsonfarms/ (showing same symptom- Virtual Weather Station (V15.00))
http://frankfortweather.us/ (showing same symptom- Virtual Weather Station (V15.00) )
http://www.madeliasliveweather.com/ (showing same symptom- Virtual Weather Station (V15.00))
http://www.carsonvalleyweather.com/wxindex.php (working normally -  Virtual Weather Station (V15.00))
http://www.glennsweatherpage.com/wxindex.php (showing same symptom- Virtual Weather Station (V15.00))
http://www.jayswoodfurniture.com/wx/index.php (showing same symptom- Virtual Weather Station (V15.00))
http://teddybearweather.com/ (showing same symptom- Virtual Weather Station (V15.00))
http://nelius.net/wx/ (showing same symptom- Virtual Weather Station (V15.00))
http://www.taylortxwx.net/ (showing same symptom- Virtual Weather Station (V15.00))
http://saratoga-weather.org/wxtemplates/Test/wxindex.php?wx=vws (working normally -  Virtual Weather Station (V15.00))

So, there is a bigger problem than I thought.  Now to reproduce it locally so I can debug....
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline HamiltonNJWeather

  • Contributor
  • ***
  • Posts: 104
    • HamiltonWeather.Net
Re: Odd Issue on Website
« Reply #20 on: April 28, 2016, 02:59:33 PM »
I just looked at my site from work, and it seems to be correct now. (?). I haven't touched a thing..


Sent from my iPhone using Tapatalk
John


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Odd Issue on Website
« Reply #21 on: April 28, 2016, 03:27:13 PM »
Ok... try this.  Change ajaxVWSwx.js
Code: [Select]
    set_ajax_obs("ajaxdate",datetime.toLocaleDateString());
    set_ajax_obs("ajaxtime",datetime.toLocaleTimeString());
    set_ajax_obs("gizmodate",datetime.toLocaleDateString());
    set_ajax_obs("gizmotime",datetime.toLocaleTimeString());
to
Code: [Select]
    var ajaxdatestr = datetime.toLocaleDateString();
    var ajaxtimestr = datetime.toLocaleTimeString();
    set_ajax_obs("ajaxdate",ajaxdatestr);
    set_ajax_obs("ajaxtime",ajaxtimestr);
    set_ajax_obs("gizmodate",ajaxdatestr);
    set_ajax_obs("gizmotime",ajaxtimestr);
and see if that fixes the issue...
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Re: Odd Issue on Website
« Reply #22 on: April 28, 2016, 03:41:25 PM »
As far as i can see, the used javascript instructions are
Code: [Select]
var ajaxtimestr = datetime.toLocaleTimeString();The documentation on http://www.w3schools.com/jsref/jsref_tolocaletimestring.asp and the examples all specify that the returned time is always the local browser time and that the input time for the date()  is always UTC.

I did not find any VWS user with other times, always my local browsers one when using Chrome - FF and Safari.
Always the exact difference between the website timezone and my local one.

This is also interesting: http://www.w3schools.com/js/js_date_formats.asp => Timezones.
Quote
In other words: If a date/time is created in GMT (Greenwich Mean Time), the date/time will be converted to CDT (Central US Daylight Time) if a user browses from central US.

At this moment
http://saratoga-weather.org/wxtemplates/Test/wxindex.php?wx=vws
gizmo => Updated:  4/28/16  21:39:53
dashboard Updated: @ 4/28/16 12:39:53pm

No idea yet why it worked previously,

Wim


Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Odd Issue on Website
« Reply #23 on: April 28, 2016, 05:25:31 PM »
Well the other odd thing is that both gizmotime and ajaxtime use the same code when created so how come one is shown differently than the other...

Offline HamiltonNJWeather

  • Contributor
  • ***
  • Posts: 104
    • HamiltonWeather.Net
Re: Odd Issue on Website
« Reply #24 on: April 28, 2016, 06:05:53 PM »
I recind my last statement... its still bugging out....going to grab dinner and a few IPA's and get at it.. Thanks for looking into this yall...  #-o  UU
John


 

anything