Branch: Tag:

2002-10-15

2002-10-15 13:29:13 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Yet another try at getting mktime() to work...

Rev: src/builtin_functions.c:1.446

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: builtin_functions.c,v 1.445 2002/10/11 01:39:29 nilsson Exp $ + || $Id: builtin_functions.c,v 1.446 2002/10/15 13:29:13 grubba Exp $   */      #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.445 2002/10/11 01:39:29 nilsson Exp $"); + RCSID("$Id: builtin_functions.c,v 1.446 2002/10/15 13:29:13 grubba Exp $");   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"
4155: Inside #if defined(HAVE_MKTIME)
  {    INT_TYPE sec, min, hour, mday, mon, year;    struct tm date; -  int retval, raw; +  int retval;       if (args<1)    SIMPLE_TOO_FEW_ARGS_ERROR("mktime", 1);
4224:   #endif /* STRUCT_TM_HAS___TM_GMTOFF */   #endif /* STRUCT_TM_HAS_GMTOFF */    -  raw = retval = mktime(&date); +  retval = mktime(&date);    -  +  if (retval == -1) +  PIKE_ERROR("mktime", "Cannot convert.\n", Pike_sp, args); +    #if defined(STRUCT_TM_HAS_GMTOFF) || defined(STRUCT_TM_HAS___TM_GMTOFF)    if((args > 7) && (Pike_sp[7-args].subtype == NUMBER_NUMBER))    {
4244:    }   #endif /* STRUCT_TM_HAS_GMTOFF || STRUCT_TM_HAS___TM_GMTOFF */    -  if (raw == -1) -  PIKE_ERROR("mktime", "Cannot convert.\n", Pike_sp, args); +  if ((args > 6) && (Pike_sp[6-args].subtype == NUMBER_NUMBER) && +  (Pike_sp[6-args].u.integer != -1) && +  (Pike_sp[6-args].u.integer != date.tm_isdst)) { +  /* Some stupid libc's (Hi Linux!) don't accept that we've set isdst... */ +  retval += 3600 * (Pike_sp[6-args].u.integer - date.tm_isdst); +  } +     pop_n_elems(args);    push_int(retval);   }