diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-04-30 17:24:38 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-04-30 17:24:38 -0300 |
commit | 82dfacbcf7fc62cfc9848808b02d935901135196 (patch) | |
tree | 93e644b70a529256905cf8669c415df3658a0ec8 /liolib.c | |
parent | 26097b6c4b28ddbf0c0d869dd657c6e00fa57a37 (diff) | |
download | lua-82dfacbcf7fc62cfc9848808b02d935901135196.tar.gz lua-82dfacbcf7fc62cfc9848808b02d935901135196.tar.bz2 lua-82dfacbcf7fc62cfc9848808b02d935901135196.zip |
detail
Diffstat (limited to 'liolib.c')
-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 `!' */ |