我正在使用struct timespec结构,这里是:
struct timespec {
time_t tv_sec; /* Seconds */
long tv_nsec; /* Nanoseconds */
};
Run Code Online (Sandbox Code Playgroud)
事实是,用户将为每个成员输入值,我想要检查最多.用户可以输入的值.
我可以拿最大值 的值time_t作为INT最大值?ie INT_MAXfor tv_sec和LONG_MAX(在limits.h中定义)tv_nsec?两者的最低可接受值是多少?它是零吗?我猜不能接受负值?只需添加,这些值将在计时器中使用.
PS:typedef在哪里time_t?在time.h.找不到它.
我.timestamp()在代码中两次使用该函数,将日期时间对象转换为纪元时间。第一次调用.timestamp()看起来像这样:
import datetime
origin_epoch = origin.timestamp()
Run Code Online (Sandbox Code Playgroud)
变量的内容origin和origin_epoch有:
同时,如果我尝试在代码的其他地方调用相同的方法
import datetime
print(datetime.datetime(1900, 1, 1, 19, 6, 28).timestamp())
Run Code Online (Sandbox Code Playgroud)
然后我收到以下错误:OSError: [Errno 22] Invalid argument这是为什么?
编辑:此错误发生在 Windows 10 上。