aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorChris Apers2005-11-07 20:06:16 +0000
committerChris Apers2005-11-07 20:06:16 +0000
commite58007674af0399dbb0bb1990a706893d571dd5b (patch)
tree272d93e777cb8eb9418a15c3261dd3410e99ff40 /backends
parent99c544869861e3a2f870f21891381dec38074c04 (diff)
downloadscummvm-rg350-e58007674af0399dbb0bb1990a706893d571dd5b.tar.gz
scummvm-rg350-e58007674af0399dbb0bb1990a706893d571dd5b.tar.bz2
scummvm-rg350-e58007674af0399dbb0bb1990a706893d571dd5b.zip
Fixed functions, not sure about the way to do this with OS version prior to 4.0
svn-id: r19496
Diffstat (limited to 'backends')
-rw-r--r--backends/PalmOS/Src/missing/_time.cpp37
1 files changed, 30 insertions, 7 deletions
diff --git a/backends/PalmOS/Src/missing/_time.cpp b/backends/PalmOS/Src/missing/_time.cpp
index f6a2220883..9ea85a93ac 100644
--- a/backends/PalmOS/Src/missing/_time.cpp
+++ b/backends/PalmOS/Src/missing/_time.cpp
@@ -22,13 +22,24 @@
#include <time.h>
-// ignore GMT, only device time
-
time_t time(time_t *tloc) {
- UInt32 secs = TimGetSeconds(); // since 1/1/1904 12AM.
- DateTimeType Epoch = {1, 0, 0, 1, 1, 1970, 0}; // form 1/1/1904 12AM to 1/1/1970 12AM
+ // get ROM version
+ UInt32 romVersion;
+ Err e = FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
+
+ // since 1/1/1904 12AM.
+ UInt32 secs = TimGetSeconds();
+
+ // form 1/1/1904 12AM to 1/1/1970 12AM
+ DateTimeType Epoch = {0, 0, 0, 1, 1, 1970, 0};
+
+ secs -= TimDateTimeToSeconds(&Epoch);
- secs -= TimDateTimeToSeconds (&Epoch);
+ // DST really supported from OS v4.0
+ if (romVersion >= sysMakeROMVersion(4,0,0,sysROMStageRelease,0))
+ secs -= (PrefGetPreference(prefTimeZone) + PrefGetPreference(prefDaylightSavingAdjustment)) * 60;
+ else
+ secs -= (PrefGetPreference(prefMinutesWestOfGMT) - 720) * 60;
if (tloc)
*tloc = secs;
@@ -39,13 +50,25 @@ time_t time(time_t *tloc) {
struct tm *localtime(const time_t *timer) {
static struct tm tmDate;
-
DateTimeType dt;
UInt32 secs = *timer;
- DateTimeType Epoch = {0, 0, 0, 1, 1, 1970, 0}; // form 1/1/1904 12AM to 1/1/1970 12AM
+
+ // get ROM version
+ UInt32 romVersion;
+ Err e = FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
+
+ // form 1/1/1904 12AM to 1/1/1970 12AM
+ DateTimeType Epoch = {0, 0, 0, 1, 1, 1970, 0};
+
// timer supposed to be based on Epoch
secs += TimDateTimeToSeconds(&Epoch);
+ // DST really supported from OS v4.0
+ if (romVersion >= sysMakeROMVersion(4,0,0,sysROMStageRelease,0))
+ secs += (PrefGetPreference(prefTimeZone) + PrefGetPreference(prefDaylightSavingAdjustment)) * 60;
+ else
+ secs += (PrefGetPreference(prefMinutesWestOfGMT) - 720) * 60; // no sure about this one
+
TimSecondsToDateTime (secs, &dt);
tmDate.tm_sec = dt.second;