FireBirdLib - Topfield TMS PVR TAP Programming Library
DST_GetTransitions_Manual.c
Go to the documentation of this file.
1#include "FBLib_time.h"
2
3void DST_GetTransitions_Manual(dword *DSTStartUTC, dword *DSTEndUTC)
4{
6
7 if(DSTStartUTCsaved != 0 && DSTEndUTCsaved != 0)
8 {
9 if(Now(NULL) < DSTStartUTCsaved && Now(NULL) < DSTStartUTCsaved)
10 {
11 if(DSTStartUTC) *DSTStartUTC = DSTStartUTCsaved;
12 if(DSTEndUTC) *DSTEndUTC = DSTEndUTCsaved;
13
14 TRACEEXIT();
15 return;
16 }
17 }
18
19 char s[24];
20 short StdOffset;
21
22 //Get both transition times from DST.ini
24 HDD_ChangeDir("/ProgramFiles/Settings");
26 {
27 GetCurrentTimeZone(&StdOffset, NULL);
28
29 if(DSTStartUTC)
30 {
31 INIGetString("DSTStartRule", s, "", sizeof(s) - 1);
32 if(s[0])
33 {
34 DST_ProcessRule(s, DSTStartUTC, 0); //This is still in local time
35
36 //Because the DST rule is expressed in local time, the opposite offset needs to be applied.
37 //The rule states "At this time (local), the offset will become x", therefore, the current offset is the opposite.
38 *DSTStartUTC = AddTime(*DSTStartUTC, -StdOffset);
39 DSTStartUTCsaved = *DSTStartUTC;
40 }
41 else
42 *DSTStartUTC = 0;
43 }
44
45 if(DSTEndUTC)
46 {
47 INIGetString("DSTEndRule", s, "", sizeof(s) - 1);
48 if(s[0])
49 {
50 DST_ProcessRule(s, DSTEndUTC, 0); //This is still in local time
51 *DSTEndUTC = AddTime(*DSTEndUTC, -StdOffset);
52 DSTEndUTCsaved = *DSTEndUTC;
53 }
54 else
55 *DSTEndUTC = 0;
56 }
57 }
58 else
59 {
60 //Failed to open DST.ini
61 if(DSTStartUTC) *DSTStartUTC = 0;
62 if(DSTEndUTC) *DSTEndUTC = 0;
63 }
66
67 TRACEEXIT();
68}
void DST_GetTransitions_Manual(dword *DSTStartUTC, dword *DSTEndUTC)
void DST_ProcessRule(char *dstRuleString, dword *dstDate, dword StartDate)
dword DSTEndUTCsaved
Definition: DST_SetDSTRule.c:4
dword DSTStartUTCsaved
Definition: DST_SetDSTRule.c:4
#define MANUALDSTINI
Definition: FBLib_time.h:6
bool HDD_ChangeDir(const char *Dir)
Definition: HDD_ChangeDir.c:5
void INICloseFile(void)
Definition: INICloseFile.c:5
bool INIGetString(char *Key, char *Value, char *DefaultValue, dword MaxLength)
Definition: INIGetString.c:5
INILOCATION INIOpenFile(char *FileName, char *AppName)
Definition: INIOpenFile.c:9
dword AddTime(dword pvrDate, int addMinutes)
Definition: AddTime.c:3
bool HDD_TAP_PushDir(void)
#define TRACEEXIT()
Definition: libFireBird.h:1244
@ INILOCATION_NewFile
Definition: libFireBird.h:2002
#define TRACEENTER()
Definition: libFireBird.h:1243
bool HDD_TAP_PopDir(void)
Definition: HDD_TAP_PopDir.c:3
dword Now(byte *Sec)
Definition: Now.c:3
bool GetCurrentTimeZone(short *TZOffset, bool *DST)