diff options
-rw-r--r-- | liolib.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 2.39 2003/03/19 21:16:12 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.40 2003/04/30 20:15:55 roberto Exp roberto $ |
3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -612,10 +612,9 @@ static int getfield (lua_State *L, const char *key, int d) { | |||
612 | 612 | ||
613 | static int io_date (lua_State *L) { | 613 | static int io_date (lua_State *L) { |
614 | const char *s = luaL_optstring(L, 1, "%c"); | 614 | const char *s = luaL_optstring(L, 1, "%c"); |
615 | time_t t = (time_t)(luaL_optnumber(L, 2, -1)); | 615 | lua_Number n = luaL_optnumber(L, 2, -1); |
616 | time_t t = (n == -1) ? time(NULL) : (time_t)n; | ||
616 | struct tm *stm; | 617 | struct tm *stm; |
617 | if (t == (time_t)(-1)) /* no time given? */ | ||
618 | t = time(NULL); /* use current time */ | ||
619 | if (*s == '!') { /* UTC? */ | 618 | if (*s == '!') { /* UTC? */ |
620 | stm = gmtime(&t); | 619 | stm = gmtime(&t); |
621 | s++; /* skip `!' */ | 620 | s++; /* skip `!' */ |