Using GPS to update RTC and then re-adjust RTC for current timezone.

Okay... this is an odd one.

This is my current code...

  DateTime now = RTC.now();  
  yearVal = now.year();
  monthVal = now.month();
  dayVal = now.day();
  hourVal = now.hour();
  minuteVal = now.minute();
  secondVal = now.second();

My application starts with a somewhat accurate local time (Pacific time - non DST). The user has the option of hooking up a GPS. My program then gets the current time (UTC time) But... i need to subtract 8 hours from it and store that back on the RTC.

I set the GPS time in the RTC with this bit of code. It works pretty good...

    RTC.adjust(DateTime(GPS.year, GPS.month, GPS.day, GPS.hour, GPS.minute, GPS.seconds));

But... once the RTC has UTC time I need to somehow subtract 8 hours and update the RTC.

I think I need to use the unixtime function and subtract 8 * 3600 from the total number of seconds but I'm still lost... What do ya'll suggest?

Does it have to be done within the same routine?

Nevermind...

This is it:

 RTC.adjust(DateTime(now.unixtime()-6*3600));

You adjust the GPS time to your local time in your sketch, BEFORE you try to put it into the RTC.

Thanks for the GPS to RTC code; worked a treat when added to my code in the section which checks for a GPS fix.