Hi,
We are working under Solaris 9 and developing with Sun Studio C++ (SS8).
After we move to winter time we got some trouble with the
mktime system call that returns a time with one hour less than the real time.
The following code returns a wrong date when the current date is November and the right date in July.
std::cout << "Build a time using mktime system call for the 20th of July 2005." << std::endl;
struct tm timeptr1;
time_t mktime_time1 ;
tzset(); // this function will set altzone which is the difference between UTC and our local time.
timeptr1.tm_mday = (unsigned) 20 ;
timeptr1.tm_mon = (unsigned) 6 ;
timeptr1.tm_year = (unsigned) 105 ;
timeptr1.tm_hour = local_tm.tm_hour ;
timeptr1.tm_min = local_tm.tm_min ;
timeptr1.tm_sec = local_tm.tm_sec ;
timeptr1.tm_isdst = daylight;
mktime_time1 = mktime(&timeptr1);
std::cout
<< "20th of july 2005 using mktime = " << mktime_time1
<< ", formatted with asctime = " << asctime (&timeptr1)
<< std::endl;
std::cout << "Build a time using mktime system call for the 20th of November 2005." << std::endl;
struct tm timeptr2;
time_t mktime_time2 ;
tzset(); // this function will set altzone which is the difference between UTC and our local time.
timeptr2.tm_mday = (unsigned) 20 ;
timeptr2.tm_mon = (unsigned) 10 ;
timeptr2.tm_year = (unsigned) 105 ;
timeptr2.tm_hour = local_tm.tm_hour ;
timeptr2.tm_min = local_tm.tm_min ;
timeptr2.tm_sec = local_tm.tm_sec ;
timeptr2.tm_isdst = daylight;
mktime_time2 = mktime(&timeptr2);
std::cout
<< "20th of November 2005 using mktime = " << mktime_time2
<< ", formatted with asctime = " << asctime (&timeptr2)
<< std::endl;
Is anybody encoutered some similar problems ?
Is there any known problem in the computation of the external variables related to the timezone environment ?
Thanks for any tips.
Yaakov Berkovitch
jaakovb@corrigent.com