Updated on Oct,24, 2001
Bug of function RimGetDateTime ?
The following practise is carried out on a Rim957, with BlackBerry SDK 2.1.
While finding the answer for one of the posts on the Developer Rim forum for
the relationship between values of member TimeZone ( of the structure TIME )
and the current zone setting on the Rim, I found a very strange thing in working
with the Date/Time of Options. The testing source ZonePrint is here.
Its main purpose is to get the TimeZone using RimGetDataTime( TIME * ). The printout
shows inconsistent values, depending on the direction that you change the timezone.
Part of the source is :
RimGetDateTime(&t);
RimSprintf( buffer, sizeof(buffer)-1, "%d",(int)(char) t.TimeZone);
m_edit.SetBuffer(20,20);
m_edit.Append(buffer);
Steps to show the bug:
Use Date/Time of application Options to set the zone as follows:
1. -Set TimeZone to -11, save this, and run the ZonePrint, it will show t.TimeZone to be -110.
2. -Set TimeZone to -10 ( using Alt - THUMP_DOWN ), save this, and run the ZonePrint, it will show t.TimeZone to be -100.
3. -Set TimeZone to -9 ( using Alt - THUMP_DOWN ), save this, and run the ZonePrint, it will show t.TimeZone to be -90.
4. -Set TimeZone to -8 ( using Alt - THUMP_DOWN ), save this, and run the ZonePrint, it will show t.TimeZone to be -70. Yes, -70, not -80, but it is
not the main point here.
5. -Set TimeZone back to to -9 ( using Alt - THUMP_UP ), save this, and run the ZonePrint, it will show t.TimeZone. This time it shows -80.
6. -Set TimeZone back to to -10 ( using Alt - THUMP_UP ), save this, and run the ZonePrint, it will show t.TimeZone. This time it shows -90.
Now we can see that in one direction of setting zones, zone -10 have value TIME.TimeZone -100, but in the other
direction, it is -90. Similar for zone -9.
Please let me know where I am wrong. I may be wrong, because now it is 2:03AM, and Z... z... z... ;-)
Nelson Bolyard showed me how to pass
around this bug: it is to use OptionsGetCurrentTimeZone() ( declared in Options.h of
the SDK ) instead of using RimGetDateTime(TIME *) to retrieve the time zone. Using this function, I can get the same
value of TimeZone no matter how I change the TimeZone via Options app.