[evolution-patches] FreeBSD7 timezone symbol incompatibility - widgets/e-timezone-dialog/e-timezone-dialog.c



Hi All,

uname -a
FreeBSD roma.home 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Sun Feb 24
19:59:52 UTC 2008    
root logan cse buffalo edu:/usr/obj/usr/src/sys/GENERIC  i386

I can't compile the subj because I have another "timezone" symbol:
char * timezone(int zone, int dst);

but in widgets/e-timezone-dialog/e-timezone-dialog.c is such code:
#ifndef G_OS_WIN32 /* Declared properly in time.h already */
extern char *tzname[2];
extern long timezone;
extern int daylight;
#endif

I see this is defined correctly on Linux but it is not on FreeBSD.

I've attached my patch.
Though there is probably need something to do with win32, because I
don't know whether there is localtime_r and gmtime_r

-- 
WBR,
Roman Rybalko

Index: widgets/e-timezone-dialog/e-timezone-dialog.c
===================================================================
--- widgets/e-timezone-dialog/e-timezone-dialog.c	(revision 36416)
+++ widgets/e-timezone-dialog/e-timezone-dialog.c	(working copy)
@@ -77,8 +77,6 @@
 
 #ifndef G_OS_WIN32 /* Declared properly in time.h already */
 extern char *tzname[2];
-extern long timezone;
-extern int daylight;
 #endif
 
 static void e_timezone_dialog_class_init	(ETimezoneDialogClass *class);
@@ -351,9 +349,16 @@
 get_local_timezone(void)
 {
 	icaltimezone *zone;
+	
+	long tzoffset;
+	time_t cur = 0; // imagine now is January the 1st 1970
+	struct tm local, gm;
+	
+	localtime_r(&cur, &local); // calls tzset()
+	gmtime_r(&cur, &gm);
+	tzoffset = (local.tm_hour - gm.tm_hour) * 3600 + (local.tm_min - gm.tm_min) * 60 + (local.tm_sec - gm.tm_sec);
 
-	tzset();
-	zone =  icaltimezone_get_builtin_timezone_from_offset (-timezone, tzname[0]);
+	zone =  icaltimezone_get_builtin_timezone_from_offset (tzoffset, tzname[0]);
 
 	return zone;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]