lua-users home
lua-l archive

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


How about an API that looked like this:

seconds, fractional_seconds = foo.time()

You'd return integer seconds as the first return value, and fractional seconds (as a floating point number) as the second result.  Code that was happy with the resolution that a floating point double yields could just carry around the sum of the two, ignoring the nanoseconds/picoseconds resolution that falls off the end.  Code that was really worried about things would use a kernel facility that actually yields results in nanoseconds or better and would carry seconds, fractional seconds around separately.

Have variations on the function, perhaps specified by an optional argument, that would allow you to tradeoff precision/resolution, accuracy and cost might be nice depending on the application. 

Louis Mamakos


On Oct 11, 2011, at 12:02 PM, Francisco wrote:

thanks, I take a care of that :P ...

On 11 October 2011 06:18, Stefan Reich <stefan.reich.maker.of.eye@googlemail.com> wrote:
I think you have tiny bug here:

 lua_pushnumber(L, ( get_time( MSEC ) + get_time( SEC ) ) );

and also here:

 lua_pushnumber( L, ( ( get_time( MSEC ) + get_time( SEC ) ) - v1 ) );

What if the current second changes between the two calls to get_time?
Rare, maybe, but not impossible.

Lint-checking is fun :)

-Stefan

On Mon, Oct 10, 2011 at 8:09 PM, Francisco <xxleite@gmail.com> wrote:
> Hello list,
> lua-time is a simple and small library that provides some time methods that
> are lacking on standart library. https://github.com/leite/lua-time
> --
> xxleite@gmail.com
> cel.: (11) 7531.7438
> site: about.leite.us
>




--
xxleite@gmail.com
cel.: (11) 7531.7438
site: about.leite.us