+?RCS: $Id$
+?RCS:
+?RCS: Copyright (c) 2008 H.Merijn Brand
+?RCS:
+?RCS: You may distribute under the terms of either the GNU General Public
+?RCS: License or the Artistic License, as specified in the README file.
+?RCS:
+?MAKE:sGMTIME_max sGMTIME_min: cat rm_try Setvar Compile run
+?MAKE: -pick add $@ %<
+?S:sGMTIME_max:
+?S: This variable defines the maximum value of the time_t offset that
+?S: the system function gmtime () accepts
+?S:.
+?S:sGMTIME_min:
+?S: This variable defines the minimum value of the time_t offset that
+?S: the system function gmtime () accepts
+?S:.
+?C:GMTIME_MAX:
+?C: This symbol contains the maximum value for the time_t offset that
+?C: the system function gmtime () accepts, and defaults to 0
+?C:.
+?C:GMTIME_MIN:
+?C: This symbol contains the minimum value for the time_t offset that
+?C: the system function gmtime () accepts, and defaults to 0
+?C:.
+?H:#define GMTIME_MAX $sGMTIME_max /**/
+?H:#define GMTIME_MIN $sGMTIME_min /**/
+?H:.
+?D:sGMTIME_max=0
+?D:sGMTIME_min=0
+?F:!try
+: Check the max offset that gmtime accepts
+echo "Checking max offset that gmtime () accepts"
+
+$cat >try.c <<'EOCP'
+#include <sys/types.h>
+#include <stdio.h>
+#include <time.h>
+int main () {
+ struct tm *tmp;
+ int i, y = 0;
+ time_t pt = 0;
+
+ for (i = 0; i < 78; i++) {
+ time_t t = (1 << i) - 1;
+ tmp = gmtime (&t);
+ if (tmp == NULL || tmp->tm_year < y) {
+ i--;
+ printf ("%d\n", pt);
+ return (i);
+ }
+
+ y = tmp->tm_year;
+ pt = t;
+ }
+ printf ("%d\n", pt);
+ return (0);
+ }
+EOCP
+set try
+if eval $compile; then
+ sGMTIME_max=`$run ./try`
+else
+ echo "Cannot determine sGMTIME_max"
+ fi
+$rm_try
+
+echo "Checking min offset that gmtime () accepts"
+
+$cat >try.c <<'EOCP'
+#include <sys/types.h>
+#include <stdio.h>
+#include <time.h>
+int main () {
+ struct tm *tmp;
+ int i, y = 70;
+ time_t pt = 0;
+
+ for (i = 0; i < 78; i++) {
+ time_t t = - (1 << i);
+ tmp = gmtime (&t);
+ if (tmp == NULL || tmp->tm_year > y) {
+ i--;
+ printf ("%d\n", pt);
+ return (i);
+ }
+
+ y = tmp->tm_year;
+ pt = t;
+ }
+ printf ("%d\n", pt);
+ return (0);
+ }
+EOCP
+set try
+if eval $compile; then
+ sGMTIME_min=`$run ./try`
+else
+ echo "Cannot determine sGMTIME_min"
+ fi
+$rm_try
+