RWZone::os() Returns Unexpected Result

Article ID: 1100
Last updated: 01 Feb, 2008
Article ID: 1100
Last updated: 01 Feb, 2008
Revision: 1
Views: 5231
Posted: 30 Sep, 1999
by Dean J.
Updated: 01 Feb, 2008
by Dean J.
Problem


  1. I get an error when using RWZone::os(). The error is similar to the following:
        error C2665: 'local' : none of the 2 overloads can 
    convert parameter 1 from type 'const class RWZone'
  2. I get an unexpected result from RWZone::os().



Cause


  1. Wrong invocation of RWZone::os().
  2. Some platforms ignore the leftover garbage in a struct tm used in a call to 'mktime(struct tm*)' and others do not. For those platforms that use the garbage, the function returns an unexpected result.



Action


  1. There is a typographical error in our Tools.h++ documentation. Setting the DST based on the underlying OS using 'RWZone::local( RWZone::os() )' as stated in our documentation, will produce an error. The error was generated because RWZone::local() can not handle 'const RWZone&' value, returned by 'os()'. Instead, RWZone::local() accepts 'const RWZone* ' value.

    The correct way to set the DST based on the OS is:

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

    instead of

    	RWZone::local(RWZone::os()) 

     

  2. This problem only affects Tools.h++ v7.1.0. One needs to identify the four(4) places in the file zone.cpp where struct tm objects are declared '(struct tm ;)' near line 93, 176, 252, and 325. Follow the statements with initializations to zero of those members not used in the call to 'mktime' separately.
    	struct tm ;
    .tm_sec = 0;
    .tm_min = 0;
    .tm_hour = 0;
    .tm_mday = 0;
    .tm_mon = 0;
    .tm_year = 0;
    .tm_wday = 0;
    .tm_yday = 0;
    .tm_isdst = 0;

    So, for zone.cpp line 93:

    	struct tm tmp;
    //test 11AM of the last day of the incoming month
    tmp.tm_year = currentYear;
    tmp.tm_mon = month;
    tmp.tm_mday = RWDate::daysInMonth[tmp.tm_mon];

    Changed to:

    	struct tm tmp;
    //zero unnecessary members
    tmp.tm_sec = 0;
    tmp.tm_min = 0;
    tmp.tm_hour = 0;
    tmp.tm_wday = 0;
    tmp.tm_yday = 0;
    tmp.tm_isdst = 0;
    //test 11AM of the last day of the incoming month
    tmp.tm_year = currentYear;
    tmp.tm_mon = month;
    tmp.tm_mday = RWDate::daysInMonth[tmp.tm_mon];

    These modifications have been implemented in our next release of Tools.h++. You can download the modified zone.cpp file here: zone.cpp.tar.

    Although at the present time MSVC 6.0 and Solaris 2.6-SunPro4.2 seem to be un-affected by a lack of initialization, to insure forward compatability, we recommend making this change on those platforms as well.

    How to apply the zone.cpp.tar:
    Untar or unzip zone.cpp.tar, go to your '/parts/tls0710u/source/src' directory if you are on Unix, or '/parts/tls0710w/source/src' directory if you are on Windows then replace your current zone.cpp file. Rebuild Tools.h++ to apply the modifications to your library.

This article was:   Helpful | Not helpful
Report an issue
Article ID: 1100
Last updated: 01 Feb, 2008
Revision: 1
Views: 5231
Posted: 30 Sep, 1999 by Dean J.
Updated: 01 Feb, 2008 by Dean J.
Attached files
item zone.cpp.tar (30 kb) Download


Others in this category