As you probably know, os.time() does not show milliseconds. This makes me wonder if it rounds up or down. Does anyone have an answer to this?
For more context, python’s time.time() shows milliseconds, so how could I convert python’s time to os.time()?
1 Like
kh_834
(sisyphus)
January 5, 2023, 2:32am
#2
I’m not very knowledge to this but I would think it would round to the closest whole number that it can do? Even without decimals it should still be able to round generally hopefully. (1:55 rounds up to 1:60 I would think??)
I’m sorry if this didn’t help but that’s my understanding.
kh_834
(sisyphus)
January 5, 2023, 2:33am
#3
okay yeah i was completely wrong, I would think it rounds up though?
I would do some testing but i’m busy right now. I’ll do some testing later and if it is I’ll mark this as the answer
Would you perhaps be interested in the DateTime
library?
-- Example
print(DateTime.now().UnixTimestampMillis) -- Prints the amount of time since the unix epoch in Milliseconds
Would this be similar to python’s time.time()?
Unfortuantely, I don’t have too much experience with Python, but looking at the documentation, I would believe so: time — Time access and conversions — Python 3.11.1 documentation
DasKairo
(Cairo)
January 5, 2023, 2:41am
#8
Small thing that might be helpful
19:40:02.677 1672886402 - Server - Script:1 -- os.time()
19:40:02.678 1672861202.1878047 - Server - Script:2 -- tick()
19:40:02.678 1672886402676 - Server - Script:3 -- DateTime.now().UnixTimestampMillis
19:40:02.678 1672886402.676 - Server - Script:4 -- DateTime.now().UnixTimestampMillis /1000
tick()
returns the exact time since the UNIX epoch however according to devices time, same with os.time()
but with UTC Time, and only seconds
os.time()
most likely rounds down according to these prints in the output using a while
loop:
19:48:27.999 1672886907 - Server - Script:2
19:48:28.477 ▶ 1672886908 (x5) - Server - Script:2
19:48:29.006 ▶ 1672886909 (x27) - Server - Script:2
19:48:30.011 ▶ 1672886910 (x28) - Server - Script:2
19:48:31.010 ▶ 1672886911 (x30) - Server - Script:2
19:48:32.009 ▶ 1672886912 (x30) - Server - Script:2
19:48:33.010 ▶ 1672886913 (x30) - Server - Script:2
19:48:34.011 ▶ 1672886914 (x11) - Server - Script:2
2 Likes
I can see why it rounds down though, for example if the time was 1.2, if it rounded up then it would be 1 second ahead.
1 Like
DasKairo
(Cairo)
January 5, 2023, 3:00am
#10
Yes, but even if it could round up like for example ( 1.5
, 1.7
, 1.9
), it would still round down to 1
with os.time()
1 Like
system
(system)
Closed
January 19, 2023, 3:00am
#11
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.