> "Barnett, Phil R" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
>
> Does anyone have a function to share that determines if the date set in
> the palm is or is not within DST?
>
> Thanks.
>
> Phil Barnett
Hi Phil,
this is my routine. I don't know how to get the system settings for the
daylight saving (day and month of beginning and end) so it's hard-coded
(european settings).
Horst
UInt32 GetDaylightAdjustment(UInt32 time) {
Int32 daylight;
DateTimeType dT;
TimSecondsToDateTime(time, &dT);
if ((dT.month == march) || (dT.month == october)) {
dT.day = DaysInMonth(dT.month, dT.year);
while (DayOfWeek(dT.month, dT.day, dT.year)) { //Sonntag = 0
--dT.day;
}
dT.minute = 0;
dT.second = 0;
dT.hour = 2;
if (dT.month == march) {
daylight = time < TimDateTimeToSeconds(&dT) ? 0 : hoursInMinutes;
}
else { /*Im Oktober ist es etwas komplizierter:
Wenn noch Sommerzeit ist, gilt diese bis 3 Uhr,
dann aber ist sozusagen ab 2 Uhr keine Sommerzeit mehr (durch die
Zeitumstellung)*/
if (PrefGetPreference(prefDaylightSavingAdjustment)) {
dT.hour = 3;
}
daylight = time < TimDateTimeToSeconds(&dT) ? hoursInMinutes : 0;
}
}
else if ((dT.month >= april) && (dT.month <= september)) {
daylight = hoursInMinutes;
}
else {
daylight = 0;
}
return daylight;
}
...
UInt32 tGS = TimGetSeconds();
//PalmOS 5 macht Sommerzeitumstellung selber (aber falsch, n�mlich im
M�rz von 1 nach 2 und Okt. von 1 auf 0 Uhr)
if (glRomVersion < sysMakeROMVersion(5, 0, 0, sysROMStageRelease, 0)) {
daylight = GetDaylightAdjustment(tGS);
diff = daylight - PrefGetPreference(prefDaylightSavingAdjustment);
if (diff) {
diff *= minutesInSeconds;
TimSecondsToDateTime(tGS, &dateTime);
TimAdjust(&dateTime, diff);
TimSetSeconds(TimDateTimeToSeconds(&dateTime));
PrefSetPreference(prefDaylightSavingAdjustment, daylight);
tGS = TimGetSeconds(); //tGS muss nach Zeitumstellung angepasst werden
}
}
...
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/