unix – 我们应该如何准备2038年?
我想认为,我今天撰写的一些软件将在30年内使用。但我也知道,很多是基于UNIX的传统,将时间作为自1970年以来的秒数。
#include <stdio.h> #include <time.h> #include <limits.h> void print(time_t rt) { struct tm * t = gmtime(&rt); puts(asctime(t)); } int main() { print(0); print(time(0)); print(LONG_MAX); print(LONG_MAX+1); } 执行结果: > Thu Jan 1 00:00:00 1970
我写了便携式替换time.h(目前只是localtime(),gmtime(),mktime()和timegm()),即使在32位机器上使用64位时间。它是打算放入C项目作为time.h的替代。它正在Perl中使用,我打算修复Ruby和Python的2038问题,以及。这给你一个安全范围的 – – 2.92亿年。
你可以找到代码at the y2038 project.请随时发表任何问题到issue tracker。 至于“这不会是另一个29年的问题”,请仔细阅读这个list of standard answers。总之,东西发生在未来,有时你需要知道什么时候。我也有a presentation on the problem,what is not a solution,and what is。 哦,不要忘记,许多时间系统不处理1970年之前的日期。东西发生在1970年之前,有时你需要知道什么时候。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- Angular2挖坑求解系列之二续:更改页面内容不会刷新之解决方
- Angular 2 html检查变量未定义,使用ngif,当值为0时排除大小
- 2016 最好的Bootstrap 管理模板
- 用wsimport在本地生成代理,调用webservice服务接口的示例
- angularjs – 如何将特定绑定传递给Angular 1.5中组件路由器
- 试图在Scala中将F有界多态作为类型成员建模
- angularjs – UI-Router – 更改$状态,而不重新布局/重新加
- scala – 睡觉演员?
- 用shell脚本启动和杀死java应用程序(Debian)
- macos – VIM:has(‘macunix’)或has(‘mac’)不起作用