64位Unix时间戳转换

是否有32位系统的64位Unix时间戳转换的C ++实现?我需要转换struct

tm为64位整数,反之亦然,包括leap年,时区和UTC。还需要它可移植,至少对于GNU / Linux和Windows而言。

回答:

你需要:

typedef long long time64_t; 

time64_t mktime64(struct tm *t);

struct tm* localtime64_r(const time64_t* t, struct tm* p);

最初(2011年),此答案包含指向2038bug.com的链接,可以在其中下载pivotal_gmtime_r包含上述功能的小型库。那时,该库已从2038bug.com中删除,链接断开并由主持人从答案中删除。pivotal_gmtime_r现在可以在这里找到类似的代码:

https://github.com/franklin373/mortage/tree/master/time_pivotal

此外,我还找到了另一个较新的库y2038,它也实现了mktime64localtime64_r

https://github.com/evalEmpire/y2038

以上是 64位Unix时间戳转换 的全部内容, 来源链接: utcz.com/qa/435461.html

回到顶部