?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 i_values
+?MAKE:sGMTIME_max sGMTIME_min sLOCALTIME_max sLOCALTIME_min: cat rm_try \
+ Setvar Compile run i_values
?MAKE: -pick add $@ %<
?S:sGMTIME_max:
?S: This variable defines the maximum value of the time_t offset that
?S: This variable defines the minimum value of the time_t offset that
?S: the system function gmtime () accepts
?S:.
+?S:sLOCALTIME_max:
+?S: This variable defines the maximum value of the time_t offset that
+?S: the system function localtime () accepts
+?S:.
+?S:sLOCALTIME_min:
+?S: This variable defines the minimum value of the time_t offset that
+?S: the system function localtime () 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: 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 /**/
+?C:LOCALTIME_MAX:
+?C: This symbol contains the maximum value for the time_t offset that
+?C: the system function localtime () accepts, and defaults to 0
+?C:.
+?C:LOCALTIME_MIN:
+?C: This symbol contains the minimum value for the time_t offset that
+?C: the system function localtime () accepts, and defaults to 0
+?C:.
+?H:#define GMTIME_MAX $sGMTIME_max /**/
+?H:#define GMTIME_MIN $sGMTIME_min /**/
+?H:#define LOCALTIME_MAX $sLOCALTIME_max /**/
+?H:#define LOCALTIME_MIN $sLOCALTIME_min /**/
?H:.
?D:sGMTIME_max=0
?D:sGMTIME_min=0
+?D:sLOCALTIME_max=0
+?D:sLOCALTIME_min=0
?F:!try
?T:yyy
-: Check the max offset that gmtime accepts
+: Check the max offset that gmtime and localtime accept
echo "Checking max offsets that gmtime () accepts"
case $i_values in
int check_max ()
{
- tmp = NULL;
- pt = 0;
+ tmp = NULL;
+ pt = 0;
#ifdef MAXLONG
- gm_check (MAXLONG);
+ gm_check (MAXLONG);
#endif
- if (tmp == NULL || tmp->tm_year < 0) {
- for (i = 63; i >= 0; i--) {
- time_t x = pt | ((time_t)1 << i);
- if (x < 0) continue;
- gm_check (x);
- }
- }
- printf ("sGMTIME_max=%ld\n", pt);
- return (0);
- }
+ if (tmp == NULL || tmp->tm_year < 0) {
+ for (i = 63; i >= 0; i--) {
+ time_t x = pt | ((time_t)1 << i);
+ if (x < 0) continue;
+ gm_check (x);
+ }
+ }
+ printf ("sGMTIME_max=%ld\n", pt);
+ return (0);
+ } /* check_max */
int check_min ()
{
- tmp = NULL;
- pt = 0;
+ tmp = NULL;
+ pt = 0;
#ifdef MINLONG
- gm_check (MINLONG);
+ gm_check (MINLONG);
#endif
- if (tmp == NULL) {
- for (i = 36; i >= 0; i--) {
- time_t x = pt - ((time_t)1 << i);
- if (x > 0) continue;
- gm_check (x);
- }
- }
- printf ("sGMTIME_min=%ld\n", pt);
- return (0);
- }
+ if (tmp == NULL) {
+ for (i = 36; i >= 0; i--) {
+ time_t x = pt - ((time_t)1 << i);
+ if (x > 0) continue;
+ gm_check (x);
+ }
+ }
+ printf ("sGMTIME_min=%ld\n", pt);
+ return (0);
+ } /* check_min */
int main (int argc, char *argv[])
{
- fprintf (stderr, "Sizeof time_t = %ld\n", sizeof (time_t));
- check_max ();
- check_min ();
- return (0);
- } /* main */
+ fprintf (stderr, "Sizeof time_t = %ld\n", sizeof (time_t));
+ check_max ();
+ check_min ();
+ return (0);
+ } /* main */
EOCP
set try
if eval $compile; then
- yyy=`$run ./try`
- eval $yyy
+ eval `$run ./try`
else
echo "Cannot determine sGMTIME_max and sGMTIME_min." >&4
fi
$rm_try
+echo "Checking max offsets that localtime () accepts"
+
+$cat >try.c <<EOCP
+#include <sys/types.h>
+#include <stdio.h>
+#include <time.h>
+$yyy
+
+int i;
+struct tm *tmp;
+time_t pt;
+
+void local_check (time_t t)
+{
+ tmp = localtime (&t);
+ if (tmp == NULL || tmp->tm_year < -1900)
+ tmp = NULL;
+ else
+ pt = t;
+ } /* local_check */
+
+int check_max ()
+{
+ tmp = NULL;
+ pt = 0;
+#ifdef MAXLONG
+ local_check (MAXLONG);
+#endif
+ if (tmp == NULL || tmp->tm_year < 0) {
+ for (i = 63; i >= 0; i--) {
+ time_t x = pt | ((time_t)1 << i);
+ if (x < 0) continue;
+ local_check (x);
+ }
+ }
+ printf ("sLOCALTIME_max=%ld\n", pt);
+ return (0);
+ } /* check_max */
+
+int check_min ()
+{
+ tmp = NULL;
+ pt = 0;
+#ifdef MINLONG
+ local_check (MINLONG);
+#endif
+ if (tmp == NULL) {
+ for (i = 36; i >= 0; i--) {
+ time_t x = pt - ((time_t)1 << i);
+ if (x > 0) continue;
+ local_check (x);
+ }
+ }
+ printf ("sLOCALTIME_min=%ld\n", pt);
+ return (0);
+ } /* check_min */
+
+int main (int argc, char *argv[])
+{
+ check_max ();
+ check_min ();
+ return (0);
+ } /* main */
+EOCP
+set try
+if eval $compile; then
+ eval `$run ./try`
+else
+ echo "Cannot determine sLOCALTIME_max and sLOCALTIME_min." >&4
+ fi
+$rm_try
+