The code logic is currently like so:

 if ($dst) {
    // we are in MDT so we use
   $utc_noon=19;
    }
    else {
    //we are in MST so we use
       $utc_noon=20;
  }

This will not work for anyone but those in the mountain time zone.

Since FWI and FBP values are location dependant, logically, these values should be abstracted back to use the hour as dictated by :

  • The local hour chosen by admin
  • Modified by local timezone DST
  • Displayed in timezone of SPARCS

This requires a new config variable in the admin panel to set the hour on which to calculate, so that stations from other timezones can still be used in local time for border stations etc.

My Thanks to Dustin Oikle (Nova Scotia) for helping me wrap my head around this issue!

Comments

spydmobile’s picture

Status: Active » Needs review

ok, here is my solution as of Commit 1aeed17 on 7.x-1.x:

          // we need to make the CFFDRS record MST/MDT sensitive so
          // We get the local noon hour chosen by administrators

          $local_cffdrs_hour=variable_get('sparcs_weather_admin_cffdrs_hour', "13");

          // Create a fake date time string with todays date but the chosen hour
          $datestring =  date('Y-m-d') . " ". $local_cffdrs_hour.":00";

          // Convert the fake noon date string into a date time object
          // This object is actually made to be the current SPARCS timezone.

          $utc_noon_object = new DateTime($datestring);
          // Now we tell the object to move to the UTC time zone.

          $utc_noon_object->setTimezone(new DateTimeZone('UTC'));

          // now we extract the UTC noon hour
          $utc_noon = $utc_noon_object->format('H');

          // test if we are in Daylight Savings Time
          $dst=date('I');
          if ($dst) {

            // we are in DST so we use
            $utc_noon = $utc_noon - 1;
          }
          else {

            //we are not in DST so we do not modify the UTC noon.
          }

THis needs testing and review......

spydmobile’s picture

there was a typo, and fixed it and committed again o.O

spydmobile’s picture

Status: Needs review » Closed (fixed)

fixed and confirmed as of Commit 792a989 on 7.x-1.x

spydmobile’s picture

Status: Closed (fixed) » Needs review

Actually this was not fixed, that was another bug, but itis fixed now.
here is the new code:

          // we need to make the CFFDRS record MST/MDT sensitive so
          // We get the local noon hour chosen by administrators
          $local_cffdrs_hour=variable_get('sparcs_weather_admin_cffdrs_hour', "13");
          // Create a fake date time string with todays date but the chosen hour
          $datestring =  date('Y-m-d') . " ". $local_cffdrs_hour.":00";
          // Convert the fake noon date string into a date time object
          // This object is actually made to be the current SPARCS timezone.
          $utc_noon_object = new DateTime($datestring,new DateTimeZone(drupal_get_user_timezone()));
          // Now we tell the object to move to the UTC time zone.
          $utc_noon_object->setTimezone(new DateTimeZone('UTC'));
          // now we extract the UTC noon hour
          $utc_noon = $utc_noon_object->format('H');
          // test if we are in Daylight Savings Time
          $dst=date('I');
          if ($dst) {
            // we are in DST so we use
            $utc_noon = $utc_noon - 1;
          }
          else {
            //we are not in DST so we do not modify the UTC noon.
          }
spydmobile’s picture

Status: Needs review » Closed (fixed)

tested, fixed as of Commit ae34c54 on 7.x-1.x

spydmobile’s picture

Issue summary: View changes

spelling and grammar