This patches NSTimeZone to use a more standard (Posix?) method of
finding the time zone info that's already set on the computer. I think
many people could avoid having to set the "Local Time Zone" default.



2003-09-01  Adam Fedor  <[EMAIL PROTECTED]>

        * configure.ac: Check for tzset
        * Source/NSTimeZone.m (+systemTimeZone): Use it to find time zone
        (as a last resort).

Index: configure.ac
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/configure.ac,v
retrieving revision 1.26
diff -u -p -r1.26 configure.ac
--- configure.ac        24 Aug 2003 02:46:30 -0000      1.26
+++ configure.ac        2 Sep 2003 02:47:57 -0000
@@ -529,7 +529,7 @@ LIBS="$saved_LIBS"
 dnl AC_REPLACE_FUNCS(getrusage gettimeofday)
 
 AC_CHECK_HEADERS(time.h sys/time.h sys/rusage.h ucbinclude/sys/resource.h)
-AC_CHECK_FUNCS(time ctime)
+AC_CHECK_FUNCS(time ctime tzset)
 
 #--------------------------------------------------------------------
 # These headers/functions needed by GSTcpPort.m
Index: Headers/Additions/GNUstepBase/config.h.in
===================================================================
RCS file: 
/cvsroot/gnustep/gnustep/core/base/Headers/Additions/GNUstepBase/config.h.in,v
retrieving revision 1.1
diff -u -p -r1.1 config.h.in
--- Headers/Additions/GNUstepBase/config.h.in   31 Jul 2003 23:49:29 -0000      1.1
+++ Headers/Additions/GNUstepBase/config.h.in   2 Sep 2003 02:47:58 -0000
@@ -6,7 +6,7 @@
 /* Define if SO_REUSEADDR is broken on this system */
 #undef BROKEN_SO_REUSEADDR
 
-/* Define if your system terminates the final argument in /proc/28891/cmdline */
+/* Define if your system terminates the final argument in /proc/$$/cmdline */
 #undef CMDLINE_TERMINATED
 
 /* Define if constructors are automatically loaded */
@@ -121,6 +121,9 @@
 /* Define to 1 if you have the `mmap' function. */
 #undef HAVE_MMAP
 
+/* Define to 1 if you have the `nanosleep' function. */
+#undef HAVE_NANOSLEEP
+
 /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
 #undef HAVE_NDIR_H
 
@@ -282,6 +285,9 @@
 /* Define to 1 if you have the <time.h> header file. */
 #undef HAVE_TIME_H
 
+/* Define to 1 if you have the `tzset' function. */
+#undef HAVE_TZSET
+
 /* Define to 1 if you have the <ucbinclude/sys/resource.h> header file. */
 #undef HAVE_UCBINCLUDE_SYS_RESOURCE_H
 
@@ -290,9 +296,6 @@
 
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
-
-/* Define to 1 if you have the `nanosleep' function. */
-#undef HAVE_NANOSLEEP
 
 /* Define to 1 if you have the `usleep' function. */
 #undef HAVE_USLEEP
Index: Source/NSTimeZone.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/base/Source/NSTimeZone.m,v
retrieving revision 1.56
diff -u -p -r1.56 NSTimeZone.m
--- Source/NSTimeZone.m 31 Jul 2003 23:49:31 -0000      1.56
+++ Source/NSTimeZone.m 2 Sep 2003 02:47:59 -0000
@@ -54,6 +54,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 #include "Foundation/NSArray.h"
 #include "Foundation/NSCoder.h"
 #include "Foundation/NSData.h"
@@ -1123,6 +1124,18 @@ static NSMapTable        *absolutes = 0;
              localZoneString = [localZoneString stringByTrimmingSpaces];
            }
        }
+#if HAVE_TZSET
+      if (localZoneString == nil)
+       {
+         /*
+          * Try to get timezone from tzset and tzname
+          */
+         extern char *tzname[2];
+         tzset();
+         if (tzname[0] != NULL && *tzname[0] != '\0')
+           localZoneString = [NSString stringWithCString: tzname[0]];
+       }
+#else
       if (localZoneString == nil)
        {
          /*
@@ -1131,6 +1144,7 @@ static NSMapTable *absolutes = 0;
          localZoneString = [[[NSProcessInfo processInfo]
            environment] objectForKey: @"TZ"];
        }
+#endif
       if (localZoneString != nil)
        {
          zone = [defaultPlaceholderTimeZone initWithName: localZoneString];
_______________________________________________
Bug-gnustep mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-gnustep

Reply via email to