Use tzset to find timezone info.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17615 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 2003-09-04 03:28:14 +00:00
parent 002578b3ec
commit c8e8f215fc
5 changed files with 30 additions and 6 deletions

View file

@ -1,3 +1,9 @@
2003-09-02 Adam Fedor <fedor@gnu.org>
* configure.ac: Check for tzset
* Source/NSTimeZone.m (+systemTimeZone): Use it to find time zone
(as a last resort).
2003-09-02 Adam Fedor <fedor@gnu.org>
* Tools/gdnc.m (main): Don't mess with file descriptors on MinGW.

View file

@ -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
@ -291,9 +297,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

View file

@ -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];

3
configure vendored
View file

@ -8321,7 +8321,8 @@ done
for ac_func in time ctime
for ac_func in time ctime tzset
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5

View file

@ -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