Hi there,
I'm quite close to finish my large wall clock project where the time base is a GPS receiver.
Nothing to worry here, everything works fine.
I have made a routine to set my DST flag ON or OFF BUT I think it must be feasible a much better way.
My code is made of all the possible cases encountered during the year and when the first positive case is reached, it leaves all others cases.
If one of you has a few moments to give it a look and come back with suggestions, I'll be very happy to see them.
Here some info about the code here under.
I live in Switzerland (EUROPE) and DST starts this year (2024) on March 31st @ 02:00 and ends on October 27th @ 03:00.
Here's my piece of code where:
- DST is a BIT var, DST 1 = summer time, DST 0 = winter time
- DayOfYear ia WORD var and is a concatenation of month (1..12) and day (1..31) - first DayOfYear = 101, last DayOfYear = 1231
- DSTStart and DSTEnd are BYTE vars and represent respectively DST ON and OFF days for that year (thanks to Enigma for his amazing formula) which are in 2024 DSTStart = 31 (March) and DSTEnd 27 (October)
- Hours is a BYTE var holding from 1..23
Code:' Before DST ON period if DayOfYear < dstStart then DST = 0 GOTO LEAVE_DST_PERIOD ENDIF ' First day of DST ON still OFF until 02:00 if DayOfYear = dstsTART then if Hours < 2 THEN DST = 0 GOTO LEAVE_DST_PERIOD ENDIF ENDIF ' First day of DST ON @ 02:00 and later if DayOfYear = dstsTART then if Hours => 2 THEN DST = 1 GOTO LEAVE_DST_PERIOD ENDIF ENDIF ' Days between DSTStart and DSTEnd if DayOfYear > dstsTART then if DayOfYear < dsteND then DST = 1 GOTO LEAVE_DST_PERIOD ENDIF ENDIF ' Last day of DST ON still ON until 03:00 if DayOfYear = dstEnd then if Hours < 3 THEN DST = 1 GOTO LEAVE_DST_PERIOD ENDIF ENDIF ' Last day of DST ON @ 03:00 and later if DayOfYear = dstEnd then if Hours => 3 THEN DST = 0 GOTO LEAVE_DST_PERIOD ENDIF ENDIF ' AFTER DST ON period if DayOfYear > dstEnd then DST = 0 GOTO LEAVE_DST_PERIOD ENDIF LEAVE_DST_PERIOD:


		
		

Bookmarks