[Scummvm-cvs-logs] CVS: scummvm/backends/PalmOS/Src/missing _time.cpp,1.8,1.9

Chris Apers chrilith at users.sourceforge.net
Mon Nov 7 12:06:42 CET 2005


Update of /cvsroot/scummvm/scummvm/backends/PalmOS/Src/missing
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24518

Modified Files:
	_time.cpp 
Log Message:
Fixed functions, not sure about the way to do this with OS version prior to 4.0

Index: _time.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/PalmOS/Src/missing/_time.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- _time.cpp	18 Oct 2005 01:30:10 -0000	1.8
+++ _time.cpp	7 Nov 2005 20:06:16 -0000	1.9
@@ -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);
 
-	secs -= TimDateTimeToSeconds (&Epoch);
+	// 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);
+
+	// 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 @@
 
 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;





More information about the Scummvm-git-logs mailing list