Hi All,
I am using RWZoneSimple object and RWTime object to check whether a given Date is falling under DST (Daylight Saving Time) or not when my server (HP-UX system) is in Non DST time (by having TZ=US/Arizona).
I have created RWZoneSimple with the date that falls in DST ("05302008"// May 30) I have updated my TZ variable to MST7MDT and executed the objRWTime.isDST() method. This was returning 1.
But after that, I have created another objRWTime with the date that falls in NON DST ("05302008"// May 30). I have updated my TZ variable to MST7 (because now I want to be in Non DST) and also I have updated my system's time to Nov, 10, 2008. Then I executed the objRWTime.isDST() method. But now the function is returning 0. I am getting this 0 even if I not updating my system's time to Nov, 10, 2008 and be in current date (May 26th).
I want to use only default US Timezone rules irrespective of the TZ variable. I am using HP-UX system.
My test program is as follows:
------------------------------
#include <rw/zone.h>
#include <rw/rwtime.h>
#include <rw/rwdate.h>
#include <rw/rstream.h>
int main(){
RWZoneSimple myZone = RWZoneSimple(RWZone::USMountain);
//RWCString myDateStr("02152008"); // NO DAYLIGHT
RWCString myDateStr("05302008"); // May 30 - DAYLIGHT
RWCString myTimeStr("05:00:00AM");
RWDate myDate(myDateStr);
RWTime *myTime = new RWTime(myDate, myTimeStr, myZone);
RWCString myDateAndTime = (*myTime).asString("%Y""%m""%d""%H""%M""%S.GMT", RWZone::utc());
cout << "myDateAndTime = " << myDateStr << myTimeStr << endl;
cout << "myDateAndTime in UTC = " << myDateAndTime << endl;
cout<<"myTime.isDST ------------>>>>>>>>>> " << (*myTime).isDST() << endl;
return 0;
}
I compile this program using "compile test.C" which has the following content:
echo "MAKEING........${1}....."
executable=`echo ${1} | cut -d'.' -f1`
/opt/aCC/bin/aCC -D_REENTRANT -DD_PTHREAD -DRWSTD_MULTI_THREAD -DHPUX_11 +eh +DA2.0 +inst_implicit_include -Wl,+n -
Wl,+s -o $executable $1 -lpthread -lm -lrwtool
In the above test program I have created a RWZone object by "RWZoneSimple myZone = RWZoneSimple(RWZone::USMountain);"
I have the DateString as "05302008" (May 30) which falls in Daylight.
Output when I set the TZ=MST7MDT:
-------------------------------------
shakila - op13 - /home/shakila/work> echo $TZ
MST7MDT
shakila - op13 - /home/shakila/work> ./trw
myDateAndTime = 0530200805:00:00AM
myDateAndTime in UTC = 20080530110000.GMT
myTime.isDST ------------>>>>>>>>>> 1
Output when I set the TZ=MST7 or TZ=US/Arizona:
--------------------------------------------------
shakila - op13 - /home/shakila/work> echo $TZ
US/Arizona
shakila - op13 - /home/shakila/work> ./test
myDateAndTime = 0530200805:00:00AM
myDateAndTime in UTC = 20080530110000.GMT
myTime.isDST ------------>>>>>>>>>> 0
I want to use only default US Timezone rules irrespective of the TZ variable. But please observe that when my TZ=MST7 or TZ=US/Arizona the output of (*myTime).isDST() is = 0.
Please Note: I am in India and my default TZ will be set to IST-5:30. So for testing these program I used set TZ to MST7MDT (to simulate that I am Daylight) or just MST7 (to simulate that I am NON-Daylight).
Kindly help me to resolve this issue. Thanks in advance.
Thanks,
Shakila.