lua-users home
lua-l archive

Re: slickest way to find out local time zone offset in pure lua?

[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(os.date("!*t", now)),
 > os.time(os.date("*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:
 do
 local now = os.time()
 localtime_minus_UTC = os.difftime(os.time(os.date("*t", now)),
 os.time(os.date("!*t", now)))
 end
I've tested this on a number of email messages (my application) and
the results look good.
Thanks!
Norman

AltStyle によって変換されたページ (->オリジナル) /