*]]
计算机科学与计算机编程中,系统时间表示在计算机系统中的时间与日期。通常用系统时钟(system clock)从某个的嘀嗒数(number of ticks)。例如,类Unix系统采用世界标准时1970年1月1日00:00:00开始的秒数(不考虑闰秒)作为UNIX时间。Windows API使用SYSTEMTIME表示年月日时分秒毫秒;使用FILETIME表示自世界标准时1601年1月1日00:00:00开始的100纳秒为单位的时钟嘀嗒数。
系统时间可以转化为日历时间以适合人去理解。例如Unix时间*'对应于日历时间2001年9月9日 01:46:40 UT*。
获取系统时间
下述均采用格里高利历与。(*)表示依赖于系统实现。
操作系统
程序设计语言与软件
不同时间的转换
Windows API提供下述数据结构表示时间:
*FILETIME:64比特整型值,表示自UTC1601年1月1日开始的每100纳秒的计数。
*SYSTEMTIME:精度到毫秒。
*time_t:64比特整型值,表示自UTC1970年1月1日开始的秒的计数。
*struct tm:精度到秒
*高分辨率性能计数器(high-resolution performance counter):每秒的滴答数。
Windows API提供下述函数:
- 本地时间与系统时间之间的转换:SystemTimeToTzSpecificLocalTime、TzSpecificLocalTimeToSystemTime
- 系统时间与文件时间的转换:SystemTimeToFileTime、FileTimeToSystemTime
- 本地时间与文件时间的转换:LocalFileTimeToFileTime、FileTimeToLocalFileTime
注释
参考文献
外部链接
- [http://people.cs.nctu.edu.tw/~tsaiwn/sisc/runtime_error_200_div_by_0/www.merlyn.demon.co.uk/critdate.htm Critical and Significant Dates] , J. R. Stockton (retrieved 3 December 2015)
- [http://www.boost.org/doc/html/date_time.html The Boost Date/Time Library] (C++)*
- [http://www.boost.org/doc/html/chrono.html The Boost Chrono Library] (C++)*
- [https://web.archive.org/web/20140405043602/http://www.chronos-st.org/ The Chronos Date/Time Library] (Smalltalk)*
- [http://www.joda.org/joda-time/ Joda Time] , The Joda Date/Time Library (Java)*
- [http://datetime.perl.org/ The Perl DateTime Project ] (Perl)*
- [http://www.ruby-doc.org/stdlib/libdoc/date/rdoc/files/date_rb.html The Ruby Date/Time Library ] (Ruby)*
评论 (0)