diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-05-14 12:57:11 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-05-14 12:57:11 -0300 |
| commit | 4ad99706493dbf3e04e26897f07147c9b6321381 (patch) | |
| tree | b506d4f73b0927c5141edffdc73dfdf857ef2f67 | |
| parent | bef345a4b8747078981e9c65b7050d65bbca6b98 (diff) | |
| download | lua-4ad99706493dbf3e04e26897f07147c9b6321381.tar.gz lua-4ad99706493dbf3e04e26897f07147c9b6321381.tar.bz2 lua-4ad99706493dbf3e04e26897f07147c9b6321381.zip | |
uses integers for time
| -rw-r--r-- | loslib.c | 10 |
1 files changed, 5 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: loslib.c,v 1.39 2012/05/23 15:37:09 roberto Exp roberto $ | 2 | ** $Id: loslib.c,v 1.40 2012/10/19 15:54:02 roberto Exp roberto $ |
| 3 | ** Standard Operating System library | 3 | ** Standard Operating System library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -194,7 +194,7 @@ static const char *checkoption (lua_State *L, const char *conv, char *buff) { | |||
| 194 | 194 | ||
| 195 | static int os_date (lua_State *L) { | 195 | static int os_date (lua_State *L) { |
| 196 | const char *s = luaL_optstring(L, 1, "%c"); | 196 | const char *s = luaL_optstring(L, 1, "%c"); |
| 197 | time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); | 197 | time_t t = luaL_opt(L, (time_t)luaL_checkinteger, 2, time(NULL)); |
| 198 | struct tm tmr, *stm; | 198 | struct tm tmr, *stm; |
| 199 | if (*s == '!') { /* UTC? */ | 199 | if (*s == '!') { /* UTC? */ |
| 200 | stm = l_gmtime(&t, &tmr); | 200 | stm = l_gmtime(&t, &tmr); |
| @@ -258,14 +258,14 @@ static int os_time (lua_State *L) { | |||
| 258 | if (t == (time_t)(-1)) | 258 | if (t == (time_t)(-1)) |
| 259 | lua_pushnil(L); | 259 | lua_pushnil(L); |
| 260 | else | 260 | else |
| 261 | lua_pushnumber(L, (lua_Number)t); | 261 | lua_pushinteger(L, t); |
| 262 | return 1; | 262 | return 1; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | 265 | ||
| 266 | static int os_difftime (lua_State *L) { | 266 | static int os_difftime (lua_State *L) { |
| 267 | lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), | 267 | lua_pushnumber(L, difftime((time_t)(luaL_checkinteger(L, 1)), |
| 268 | (time_t)(luaL_optnumber(L, 2, 0)))); | 268 | (time_t)(luaL_optinteger(L, 2, 0)))); |
| 269 | return 1; | 269 | return 1; |
| 270 | } | 270 | } |
| 271 | 271 | ||
