FreeBSD7 timezone symbol incompatibility - widgets/e-timezone-dialog/e-timezone-dialog.c

Roman Rybalko <[email protected]> Wed, 24 Sep 2008 18:54:20 +0400
Newsgroups gmane.comp.gnome.evolution.patches,gmane.comp.gnome.evolution.devel
Message-ID <[email protected]>
--------------050808040407040901050404
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7bit

Hi All,

uname -a
FreeBSD roma.home 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Sun Feb 24
19:59:52 UTC 2008    
[email protected]:/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


--------------050808040407040901050404
Content-Type: text/x-patch; name="timezone-freebsd7-fix.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="timezone-freebsd7-fix.patch"

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;
 }

--------------050808040407040901050404
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Evolution-patches mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/evolution-patches

--------------050808040407040901050404--