代码之家  ›  专栏  ›  技术社区  ›  sap

RWTime正在显示localtime+1

  •  1
  • sap  · 技术社区  · 15 年前

    为什么时间多给了你一个小时

    #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

    2 回复  |  直到 15 年前
        1
  •  1
  •   Eugene Smith    15 年前

    我的第六感很刺痛,它告诉我答案与夏令时有关。。。但我不知道为什么。。。

        2
  •  0
  •   DRH    14 年前

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

    RWZone::local(&RWZone::os());
    
    推荐文章