Posted: Tue Dec 29, 2015 11:57 am Post subject: Daylight saving
Here is some code To get a GPS to show daylight saving time.
the sub routine will return a 1 if you are in DST.
in your code, add:
Code:
Config Clock = User 'Use USER to write/use your own code ConfigDate= Dmy , Separator ="-" Dim DST asbit Dim currenttime aslong Dim Fullyear AsInteger Dim Times AsInteger Dim Division AsInteger Dim Calcbuf AsInteger Dim Dststartday AsByte Dim Dststopday AsByte Dim Dststartdate AsLong Dim Dststopdate AsLong DeclareSub Dstcheck
The only thing needed from the GPS is the year (last 2 digits) string.
if DST = 1, add 3600 to your time.
Fullyear =Val(yy)+2000'for the calculations we need a 4 digit year like 2015 yy is the year string coming from my GPS ' for _year= we need only the 2 last digits. 'had lots of trouble with _year=val(right(yy,2)) hence this "work around" ' find start day dst
Times =5* Fullyear
Division = Times /4
Calcbuf = Division +4
Calcbuf = Calcbuf Mod7
Dststartday =31- Calcbuf
' find stop day dst ' we did the other stuff allready
Calcbuf = Division +1
Calcbuf = Calcbuf Mod7
Dststopday =31- Calcbuf
'plug in the rest to make a DST start and stop date and hour
_sec =0: _min =0: _hour =2: _day = Dststartday : _month =3: _year =Val(yy)
Dststartdate =Syssec()
_sec =0: _min =0: _hour =2: _day = Dststopday : _month =10: _year =Val(yy)
Dststopdate =Syssec() 'it is so nice that you can do calculations when everything is in syssec If Currenttime >= Dststartdate And Currenttime <= Dststopdate ThenSet Dst ElseReset Dst
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum