51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2108|回复: 0
打印 上一主题 下一主题

[求助] vugen函数帮助文档asctime中的例子打印的小时值不对

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2014-8-30 13:57:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
下面代码拷贝自vugen函数帮助文档asctime中的例子,发现打印出的最终结果中小时的值是错误的。用ctime(&t)打印出来的时间才是正确的。是什么原因呢?

Action()
{
        typedef long time_t;

    struct tm {

        int tm_sec; // seconds after the minute - [0,59]

        int tm_min; // minutes after the hour - [0,59]

        int tm_hour; // hours since midnight - [0,23]

        int tm_mday; // day of the month - [1,31]

        int tm_mon; // months since January - [0,11]

        int tm_year; // years since 1900

        int tm_wday; // days since Sunday - [0,6]

        int tm_yday; // days since January 1 - [0,365]

        int tm_isdst; // daylight savings time flag

    #ifdef LINUX

        int tm_gmtoff;

        const char *tm_zone;

    #endif

    };

    time_t t;

    struct tm *gmt;

    time(&t); //Returns the system time.

    gmt = (struct tm *)gmtime(&t); //gmtime():Converts the system time into Coordinated Universal Time (UTC).

    lr_message ("Coordinated universal time:\t\t%s", asctime(gmt));
lr_message ("The systime is : %s",ctime(&t));

return 0;
}
打印结果如下:
Coordinated universal time:         Sat Aug 30 05:49:23 2014
The systime is : Sat Aug 30 13:49:23 2014
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-9-28 10:59 , Processed in 0.075773 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表