Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add milliseconds (or lower) to time() function #7

Open
tscheer86 opened this issue Aug 20, 2020 · 4 comments
Open

Add milliseconds (or lower) to time() function #7

tscheer86 opened this issue Aug 20, 2020 · 4 comments

Comments

@tscheer86
Copy link

Unable to use time() to monitor less than seconds.

@waywardmonkeys
Copy link
Contributor

It isn't optimal really, but there is mtime() that returns microseconds ... so the code that uses that tends to look like [time(), mtime()].

Is that sufficient?

@saulren
Copy link

saulren commented Mar 14, 2021

I believe he was asking due to an anti spam measure I implemented into the $player parser. Currently it limits inputs to 1/second and with this function I should be able to divide that time. Thanks for the reply!

@waywardmonkeys
Copy link
Contributor

#17 may be a useful first step to doing this.

@lisdude
Copy link

lisdude commented Nov 18, 2022

In MOO we've settled on separating this into an ftime() function that handily returns a float like 1668748884.14323. In that spirit, I added the method $time.ftime() with the code:

return tofloat(time() + "." + mtime());

Seems to work. It's also a nice option for not messing with the driver.

For fun, though, I also ported the ftime builtin function that I wrote for ToastStunt. It provides the same time + mtime combination, but it also includes an argument to return monotonic time. The gist of which (ho ho) can be found here if interested: https://gist.github.com/lisdude/b8f7d6ee3fc48788ba83e6b1691d7566

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants