diff options
Diffstat (limited to 'loslib.c')
-rw-r--r-- | loslib.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: loslib.c,v 1.12 2005/08/26 17:36:32 roberto Exp roberto $ | 2 | ** $Id: loslib.c,v 1.13 2005/09/09 18:22:46 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 | */ |
@@ -125,8 +125,8 @@ static int getfield (lua_State *L, const char *key, int d) { | |||
125 | 125 | ||
126 | static int io_date (lua_State *L) { | 126 | static int io_date (lua_State *L) { |
127 | const char *s = luaL_optstring(L, 1, "%c"); | 127 | const char *s = luaL_optstring(L, 1, "%c"); |
128 | lua_Number n = luaL_optnumber(L, 2, -1); | 128 | time_t t = lua_isnoneornil(L, 2) ? time(NULL) : |
129 | time_t t = (n == -1) ? time(NULL) : (time_t)n; | 129 | (time_t)luaL_checknumber(L, 2); |
130 | struct tm *stm; | 130 | struct tm *stm; |
131 | if (*s == '!') { /* UTC? */ | 131 | if (*s == '!') { /* UTC? */ |
132 | stm = gmtime(&t); | 132 | stm = gmtime(&t); |