Why RWTime is giving 1 hour more
#include <rw/rwtime.h>
#include <rw/rwdate.h>
#include <rw/rstream.h>
main(){
RWTime t; // Current time
RWTime d(RWTime::beginDST(199开发者_开发技巧0, RWZone::local()));
cout << "Current time: " << RWDate(t) << " " << t <<
endl;
cout << "Start of DST, 1990: " << RWDate(d) << " " << d <<
endl;
}
Above program prints:
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
But date
gives:
root@otp42mas:/home/nmsadm/sapna/cProgS# date
Wed Oct 27 16:08:10 IST 2010
My sixth sense is tingling, it tells me that the answer has something to do with the daylight savings time ... I'm not sure why, though ...
By default RWZone::local()
will return an RWZone implementation based on North American DST transitions. RWZone::os()
provides an RWZone implementation based DST transitions derived from the current system time zone. RWZone::local()
can be updated to use RWZone::os()
using:
RWZone::local(&RWZone::os());
精彩评论