FireBirdLib - Topfield TMS PVR TAP Programming Library
DST_GetNextTransition.c
Go to the documentation of this file.
1#include "FBLib_time.h"
2
3dword DST_GetNextTransition(byte ruleOrdinal, byte ruleDay, byte ruleMonth, byte ruleHour, byte ruleMin, word ruleYear)
4{
6
7 word tempDate;
8 dword returnDate;
9 word year;
10 byte month, day, weekDay;
11
12 tempDate = TAP_MakeMjd(ruleYear, ruleMonth, 1); //Get the first day of the transition month;
13
14 TAP_ExtractMjd(tempDate, &year, &month, &day, &weekDay);
15
16 tempDate = tempDate + ruleDay - weekDay;
17
18 if(weekDay > ruleDay)
19 {
20 tempDate = tempDate + (ruleOrdinal * 7);
21 }
22 else
23 {
24 tempDate = tempDate + ((ruleOrdinal - 1) * 7);
25 }
26
27 TAP_ExtractMjd(tempDate, &year, &month, &day, &weekDay);
28
29 if(month != ruleMonth) {tempDate = tempDate - 7;} //An ordinal of 5 can sometimes land in next month
30
31 returnDate = ((tempDate & 0xffff) << 16) | ((ruleHour & 0xff) << 8) | (ruleMin & 0xff);
32
33 TRACEEXIT();
34 return returnDate;
35}
dword DST_GetNextTransition(byte ruleOrdinal, byte ruleDay, byte ruleMonth, byte ruleHour, byte ruleMin, word ruleYear)
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243