pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/   /**/   #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"   #include "object.h"   #include "program.h"   #include "array.h"   #include "pike_error.h"   #include "constants.h"   #include "mapping.h"   #include "stralloc.h"
pike.git/src/builtin_functions.c:3986: Inside #if defined(HAVE_GMTIME)
  PMOD_EXPORT void f_gmtime(INT32 args)   {    struct tm *tm;    INT_TYPE tt;    time_t t;       get_all_args("gmtime", args, "%i", &tt);       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"));    push_int(0);    f_aggregate_mapping(20);   }   #endif      #ifdef HAVE_LOCALTIME   /*! @decl mapping(string:int) localtime(int timestamp)
pike.git/src/builtin_functions.c:4030: Inside #if defined(HAVE_LOCALTIME)
   *! @elem int(0..6) "wday"    *! Day of week (0 = Sunday).    *! @elem int(0..365) "yday"    *! Day of the year.    *! @elem int(0..1) "isdst"    *! Is daylight savings time.    *! @elem int "timezone"    *! 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].    *!    *! @note    *! The field @tt{"timezone"@} may not be available on all platforms.    *!    *! @seealso    *! @[Calendar], @[gmtime()], @[time()], @[ctime()], @[mktime()]    */   PMOD_EXPORT void f_localtime(INT32 args)   {    struct tm *tm;    INT_TYPE tt;    time_t t;       get_all_args("localtime", args, "%i", &tt);       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    push_string(make_shared_string("timezone"));    push_int(-tm->tm_gmtoff);    f_aggregate_mapping(20);   #else   #ifdef STRUCT_TM_HAS___TM_GMTOFF    push_string(make_shared_string("timezone"));    push_int(-tm->__tm_gmtoff);