lua-users home
lua-l archive

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

Vaughan McAlley wrote:
Thanks for the help. It's nice to know I can use the Lua timestamps
and they won't be translating as 1639 on Windows clients. The closest
thing to the Unix time-stamp on Windows seems to be FileTime, a 64-bit
integer counting 100-nanosecond intervals from 1601, which wouldn't
work with Lua numbers.

When you want to view a FileTime as a sane local time, you'd have to make another two calls to FileTimeToLocalFileTime and FileTimeToSystemTime, the result of the latter can then be loaded into a Lua table. IIRC, in Cygwin, they subtract a FileTime by a big number to get to the Unix epoch, then scale accordingly. In most cases it is easier to use the C library, but sometimes it is necessary to write your own file system layer, e.g. to use Unicode filenames in Win32.

Thu Jan  1 00:00:01 1970

Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia