lua-users home
lua-l archive

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

 > On Wed, Mar 05, 2008 at 08:33:08AM -0500, Louis Mamakos wrote:
 > In fact, I think this is a shorter, more correct result of figuring
 > out the offset between local time and UTC:
 > now = os.time()
 > UTC_offset_seconds = os.difftime(os.time("!*t", now)),
 >                                  os.time("*t", now)))
 > This presumes os.time() on UNIX returns number of seconds since the
 > epoch, of course.

Thanks; I've used your solution almost identically except I decided I
wanted the opposite sign:

    local now = os.time()
    localtime_minus_UTC = os.difftime(os.time("*t", now)),
                                      os.time("!*t", now)))

I've tested this on a number of email messages (my application) and
the results look good.