C专家编程-前言

C专家编程-前言中提出的一个有关时间最大值小问题。
在time.h中 time_t是long的typedef形式。long和int在标准C中都为32bits
#include <stdio.h>
#include <time.h>

int main()
{
time_t biggest = 0x7FFFFFFF;
/* ctime() function converts the calendar time time to local
   time of the format */
printf("biggest = %s \n",ctime(&biggest));
/* gmtime() function returns the given time in Coordinated
   Universal Time
   asctime() converts the time in the struct 'ptr' to a
   character string of the following format:
   day month date hours:minutes:seconds year     */
printf("biggest = %s \n", asctime(gmtime(&biggest)));
return 0;
}
输出结果为:
97d864f235651722b17ec526.jpg
ctime()函数把参数转换为当地时间,它跟世界统一时间UTC并不一致,取决于你所在的时区。在中国得到的最大时间就要比标准格林尼治时间多8个小时。
如果你采用的是新西兰的时区,时间又会发生改变,而且新西兰有一部分位于日界线的东面,因此又会产生不同的时间结果。
如果有人觉得对日期编程是小菜一碟,一次动手便可轻松搞定,那么他肯定没有深入研究问题,程序的质量也可想而知。--Peter Van Der Linden

转载于:https://www.cnblogs.com/aquar/archive/2010/01/10/3451486.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值