相关疑难解决方法(0)

time_t的最大值(struct timespec)

我正在使用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_secLONG_MAX(在limits.h中定义)tv_nsec?两者的最低可接受值是多少?它是零吗?我猜不能接受负值?只需添加,这些值将在计时器中使用.

PS:typedef在哪里time_t?在time.h.找不到它.

c linux time

14
推荐指数
4
解决办法
3万
查看次数

为什么 Datetime 的 `.timestamp()` 方法返回 `OSError: [Errno 22] Invalid argument`?

.timestamp()在代码中两次使用该函数,将日期时间对象转换为纪元时间。第一次调用.timestamp()看起来像这样:

import datetime    
origin_epoch = origin.timestamp()
Run Code Online (Sandbox Code Playgroud)

变量的内容originorigin_epoch有:

Visual Studio Code 的变量调试器的屏幕截图。

同时,如果我尝试在代码的其他地方调用相同的方法

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 上。

python datetime epoch python-3.x

5
推荐指数
2
解决办法
1208
查看次数

标签 统计

c ×1

datetime ×1

epoch ×1

linux ×1

python ×1

python-3.x ×1

time ×1