Branch: Tag:

2002-10-03

2002-10-03 17:23:38 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.92
Rev: src/builtin_functions.c:1.442

1:   /* -*- c -*- -  * $Id: builtin.cmod,v 1.91 2002/10/03 16:04:56 mast Exp $ +  * $Id: builtin.cmod,v 1.92 2002/10/03 17:23:38 mast Exp $    */      #include "global.h"
340:    *! Convert the output from a previous call to @[time()] into a readable    *! string containing the current year, month, day and time.    *! -  *! Like @[localtime], this function might return zero if the ctime(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]. +  *! Like @[localtime], this function might throw an error if the +  *! ctime(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].    *!    *! @seealso    *! @[time()], @[localtime()], @[mktime()], @[gmtime()]
354:   {    time_t i=(time_t)timestamp;    char *s = ctime (&i); -  if (!s) { -  pop_stack(); -  push_int (0); -  return; -  } +  if (!s) Pike_error ("ctime() on this system cannot handle " +  "the timestamp %ld.\n", (long) i);    RETURN make_shared_string(s);   }