lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,

I am a newcomer to lua, and what a marvelous language it is! I've
already done things with it that I wouldn't have even ventured in
perl, etc.

Here is a question regarding os.time():

[0 ~/lua/lib]$ date -d 01/01/1970 +%s
25200

[0 ~/lua/lib]$ lua
Lua 5.1.1  Copyright (C) 1994-2006 Lua.org, PUC-Rio
lua> print (os.date("%s", os.time{year=1970,month=01,day=01}))
68400

[0 ~/lua/lib]$ date -d @25200
Thu Jan  1 00:00:00 MST 1970
[0 ~/lua/lib]$ date -d @68400
Thu Jan  1 12:00:00 MST 1970

ie, on my GNU/Linux system, the call to date with no time specified
gives it to me at midnight in my locale's timezone, whereas lua gives
it to me at noon. In my conversion routine, I subtract 12*60*60 from
the result, as it is likely that these data files will have input to
them from other sources which use the midnight convention, and I want
to be able to accurately compare the dates, but just wonder why the
different behaviours?

Thanks,
Scott.