FireBirdLib - Topfield TMS PVR TAP Programming Library
UTC2LocalTime.c
Go to the documentation of this file.
1#include "FBLib_time.h"
2
3dword UTC2LocalTime(dword UTCTime, short *Offset)
4{
6
7 short StdOffset, DSTOffset;
8 dword DSTStartUTC, DSTEndUTC;
9 bool DST;
10 dword ret;
11
13
14 //Read the timezone settings from the flash
15 if(!GetCurrentTimeZone(&StdOffset, &DST)) StdOffset = 60;
16
17 switch(DSTRule)
18 {
19 case DSTR_Undefined:
20 case DSTR_Firmware:
21 {
22 //This one uses the "cheap" solution from the firmware. A look-ahead is not possible.
23 if(Offset) *Offset = StdOffset + (DST ? 60 : 0);
24
25 ret = Appl_TimeToLocal(UTCTime);
26
27 TRACEEXIT();
28 return ret;
29 }
30
31 case DSTR_Europe:
32 {
33 DST_GetTransitions_Europe(&DSTStartUTC, &DSTEndUTC, UTCTime);
34 break;
35 }
36
37 case DSTR_Manual:
38 {
39 //Takes the rule out of DST.ini
40 DST_GetTransitions_Manual(&DSTStartUTC, &DSTEndUTC);
41 break;
42 }
43 }
44
45 if(DSTStartUTC < DSTEndUTC)
46 {
47 //We are currently in standard time
48 DSTOffset = 0;
49
50 //Is UTCTime in DST?
51 if((UTCTime >= DSTStartUTC) && (UTCTime < DSTEndUTC)) DSTOffset = 60;
52 }
53 else
54 {
55 //We are currently in DST
56 DSTOffset = 60;
57
58 //Is UTCTime in standard TZ?
59 if((UTCTime >= DSTEndUTC) && (UTCTime < DSTStartUTC)) DSTOffset = 0;
60 }
61
62 if(Offset) *Offset = StdOffset + DSTOffset;
63 ret = AddTime(UTCTime, StdOffset + DSTOffset);
64
65 TRACEEXIT();
66 return ret;
67}
dword Appl_TimeToLocal(dword UTCTime)
void DST_GetDefaultDSTRule(void)
void DST_GetTransitions_Europe(dword *DSTStartUTC, dword *DSTEndUTC, dword StartDate)
void DST_GetTransitions_Manual(dword *DSTStartUTC, dword *DSTEndUTC)
tDSTRule DSTRule
Definition: DST_SetDSTRule.c:3
dword UTC2LocalTime(dword UTCTime, short *Offset)
Definition: UTC2LocalTime.c:3
dword AddTime(dword pvrDate, int addMinutes)
Definition: AddTime.c:3
#define TRACEEXIT()
Definition: libFireBird.h:1244
@ DSTR_Firmware
Definition: libFireBird.h:2697
@ DSTR_Europe
Definition: libFireBird.h:2698
@ DSTR_Manual
Definition: libFireBird.h:2699
@ DSTR_Undefined
Definition: libFireBird.h:2696
#define TRACEENTER()
Definition: libFireBird.h:1243
bool GetCurrentTimeZone(short *TZOffset, bool *DST)