datetime - os.difftime(t2, t1) 的用途是什么,但 t2 - t1 未涵盖?

标签 datetime lua

在此代码中

t1 = os.time()
do_something_slow()
t2 = os.time()

elapsed_diff = os.difftime(t2, t1)
elapsed_sub  = t2 - t1

什么情况下elapsed_diff会与elapsed_sub不同?

最佳答案

在非Posix系统中,不能保证os.time返回的值可以直接相减。

In the GNU C Library, you can simply subtract time_t values. But on other systems, the time_t data type might use some other encoding where subtraction doesn't work directly. [1]

关于datetime - os.difftime(t2, t1) 的用途是什么,但 t2 - t1 未涵盖?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24585840/

相关文章:

python - Matplotlib x 轴日期刻度频率

C# 反射 : Emit DateTime Property Value

sql - 如何将存储在 varchar2 中的时间转换为 Oracle 中的 24 小时格式?

lua - LUA 5.1 中的评估函数

mysql - 请求日期时间元素时出现 NoMethodError

c# - 更改 ASCX 文件中的日期格式

Lua 检查数字/值是否为 nan

c - 如何在没有 luarocks 的情况下编译 LuaFileSystem 库并获取 .dll 文件?

c++ - Lua OOP 函数没有被调用?

lua - Corona中的触摸事件什么时候有 "cancelled"阶段?