PDA

View Full Version : RW Time for DST ISSUE



GaryCopp
10-29-2009, 07:32 AM
We are having an issue with the RW Time object translating times into DST. We are setting an object to the current server time, but it is changing the time by one hour. How do we prevent this from happening? The server already with handle the DST and we don't want RW time to adjust for this.

Simple sample with output.

Update: We tried using RWTime t(timeinfo, RWZone::os()); command, but this did not work.

---------------------------------------------------------
#include <iostream>
#include <rw/cstring.h>
#include <rw/rwdate.h>
#include <rw/rwtime.h>

using namespace std;

int main()
{
time_t rawtime;
struct tm * timeinfo;

time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf ( "Current local time and date: %s", asctime (timeinfo) );
RWZone::local(new RWZoneSimple(RWZone::USEastern,RWZone::NoDST));
RWTime t(timeinfo, RWZone::local());
cout << " RW Time : " << t << endl;

return 1;
}


> ./RWT1.exe
Current local time and date: Thu Oct 29 10:08:47 2009
RW Time : 10/29/09 09:08:47

dean
10-29-2009, 08:22 AM
Gary,

I would change your RWZone::local to use the Operating System DST rules.To install the underlying system's DST rule as your global local time, use:

RWZone::local( &RWZone::os() );

This should solve the problem you are seeing.

Jeremy

GaryCopp
10-29-2009, 08:51 AM
Thanks for the quick response. We tried that, and it didn't work.

#include <iostream>
#include <rw cstring.h="">
#include <rw rwdate.h="">
#include <rw rwtime.h="">

using namespace std;

int main()
{
time_t rawtime;
struct tm * timeinfo;

time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf ( "Current local time and date: %s", asctime (timeinfo) );

//RWZone::local(new RWZoneSimple(RWZone::USEastern,RWZone::NoDST));

//RWTime t(timeinfo, RWZone::local( &RWZone::os()));
RWTime t(timeinfo, RWZone::os());
cout << " RW Time : " << t << endl;

return 1;
}

> ./RWT1.exe
Current local time and date: Thu Oct 29 11:43:19 2009
RW Time : 10/29/09 10:43:19

UNIX version : UNIX IBM AIX 6.1
Source Por version : SourcePro C++ Edition 9</rw></rw></rw></iostream>

GaryCopp
10-29-2009, 01:16 PM
Thanks for the quick response. We tried that change, but it did not help.
Here's the code with the changes, but the same results.

#include <iostream>
#include <rw cstring.h="">
#include <rw rwdate.h="">
#include <rw rwtime.h="">

using namespace std;

int main()
{
time_t rawtime;
struct tm * timeinfo;

time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf ( "Current local time and date: %s", asctime (timeinfo) );

//RWZone::local(new RWZoneSimple(RWZone::USEastern,RWZone::NoDST));

//RWTime t(timeinfo, RWZone::local( &RWZone::os()));
RWTime t(timeinfo, RWZone::os());
cout << " RW Time : " << t << endl;

return 1;
}

> ./RWT1.exe
Current local time and date: Thu Oct 29 16:14:49 2009
RW Time : 10/29/09 15:14:49</rw></rw></rw></iostream>