Branch: Tag:

2002-10-03

2002-10-03 17:23:29 by Martin Stjernholm <mast@lysator.liu.se>

It's better to throw errors than return zero if ctime(), localtime() or
gmtime() fails.

Rev: src/builtin.cmod:1.29
Rev: src/builtin_functions.c:1.363

5:   \*/   /**/   #include "global.h" - RCSID("$Id: builtin_functions.c,v 1.362 2002/10/03 15:22:11 mast Exp $"); + RCSID("$Id: builtin_functions.c,v 1.363 2002/10/03 17:23:29 mast Exp $");   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"
3993: Inside #if defined(HAVE_GMTIME)
      t = tt;    tm = gmtime(&t); +  if (!tm) Pike_error ("gmtime() on this system cannot handle " +  "the timestamp %ld.\n", (long) t);    pop_n_elems(args); -  -  if (!tm) { -  push_int (0); -  return; -  } +     encode_struct_tm(tm);       push_string(make_shared_string("timezone"));
4037: Inside #if defined(HAVE_LOCALTIME)
   *! Offset from UTC.    *! @endmapping    *! -  *! Zero is returned if the localtime(2) call failed on the system. +  *! An error is thrown if the localtime(2) call failed on the system.    *! It's platform dependent what time ranges that function can handle,    *! e.g. Windows doesn't handle a negative @[timestamp].    *!
4057: Inside #if defined(HAVE_LOCALTIME)
      t = tt;    tm = localtime(&t); +  if (!tm) Pike_error ("localtime() on this system cannot handle " +  "the timestamp %ld.\n", (long) t);    pop_n_elems(args); -  -  if (!tm) { -  push_int (0); -  return; -  } +     encode_struct_tm(tm);      #ifdef STRUCT_TM_HAS_GMTOFF