update Wed Feb 10 06:37:00 PST 2010
[pkgsrc.git] / lang / swi-prolog-lite / patches / patch-ak
1 $NetBSD: patch-ak,v 1.1 2006/10/12 14:14:13 joerg Exp $
2
3 --- src/pl-tai.c.orig   2006-07-28 09:20:12.000000000 +0000
4 +++ src/pl-tai.c
5 @@ -38,11 +38,8 @@ long set by tzset().  Not really clean .
6  
7  #ifdef WIN32
8  #define timezone _timezone
9 -#define daylight _daylight
10  #else
11  extern char *tzname[2];
12 -extern long timezone;
13 -extern int daylight;
14  #endif
15  
16  
17 @@ -82,8 +79,21 @@ do_tzset()
18  
19  static int
20  tz_offset()
21 -{ do_tzset();
22 -  return timezone;
23 +{
24 +  time_t now = time(NULL), t_gmt, t_local;
25 +  struct tm gmt, local;
26 +  int diff;
27 +
28 +  do_tzset();
29 +  gmtime_r(&now, &gmt);
30 +  t_gmt = mktime(&gmt);
31 +  localtime_r(&now, &local);
32 +  t_local = mktime(&local);
33 +  diff = t_local - t_gmt;
34 +  if (local.tm_isdst)
35 +    diff += 3600;
36 +
37 +  return diff;
38  }
39  
40  
41 @@ -312,14 +322,12 @@ PRED_IMPL("stamp_date_time", 3, stamp_da
42           ct.hour       = tm.tm_hour;
43           ct.minute     = tm.tm_min;
44           tzatom = tz_name_as_atom(tm.tm_isdst);
45 -         if ( daylight )                       /* from tzset() */
46 -         { if ( tm.tm_isdst )
47 +         if ( tm.tm_isdst )
48             { utcoffset -= 3600;
49               dstatom    = ATOM_true;
50             } else
51             { dstatom    = ATOM_false;
52             }
53 -         }
54           done = TRUE;
55         }
56        } else if ( alocal == ATOM_utc )
57 @@ -721,12 +729,10 @@ PRED_IMPL("format_time", 3, format_time,
58      { localtime_r(&unixt, &tb.tm);
59        tb.sec = (double)tb.tm.tm_sec + modf(tb.stamp, &ip);
60        tb.utcoff = tz_offset();
61 -      if ( daylight )
62 -      { if ( tb.tm.tm_isdst )
63 +      if ( tb.tm.tm_isdst )
64         { tb.utcoff -= 3600;
65           tb.isdst = TRUE;
66         }
67 -      }
68        tb.tzname = tz_name_as_atom(tb.tm.tm_isdst);
69        tb.flags  = HAS_STAMP|HAS_WYDAY;
70      } else