1

为什么 RWTime 多给了 1 小时

#include <rw/rwtime.h>
#include <rw/rwdate.h>
#include <rw/rstream.h>

main(){
 RWTime t;   // Current time
 RWTime d(RWTime::beginDST(1990, RWZone::local()));
   cout << "Current time:         " << RWDate(t) << " " << t <<
            endl;
   cout << "Start of DST, 1990:   " << RWDate(d) << " " << d <<
           endl;
}

上面的程序打印:

root@otp42mas:/home/nmsadm/sapna/cProgS# ./a.out
Current time: 10/27/10 10/27/10 17:08:06
Start of DST, 1990: 04/01/90 04/01/90 03:00:00

但是date给出:

root@otp42mas:/home/nmsadm/sapna/cProgS# date
Wed Oct 27 16:08:10 IST 2010

4

2 回答 2

1

我的第六感在刺痛,它告诉我答案与夏令时有关......我不知道为什么,虽然......

于 2010-10-27T11:02:38.477 回答
0

默认情况下RWZone::local(),将返回基于北美 DST 转换的 RWZone 实现。RWZone::os()提供从当前系统时区派生的基于 RWZone 实现的 DST 转换。RWZone::local()可以更新RWZone::os()使用:

RWZone::local(&RWZone::os());
于 2011-12-03T03:44:22.800 回答