Ludicrous Software

For Want of a Minus Sign

It’s amazing what a difference a minus sign can make: it is, in fact, the difference between Winnipeg and Mumbai - at least from the perspective of UTC (or Greenwich Mean Time) offsets. Winnipeg is UTC - 5 hours, Mumbai is UTC + 5 hours. But a bug in Flash Lite has Winnipeg, and every other place in UTC - 5, way over on the other side of the world.

If you want to find out the time zone offset on a device running Flash Lite, you can use:

fscommand2("GetTimeZoneOffset", "timezoneoffset");

If the device supports this particular command, then timezoneoffset is set to the number of minutes between the time zone on the user’s device and UTC. This number would be plus or minus depending upon the side of Greenwich that particular time zone is on. In Winnipeg, since it’s at UTC - 5 hours, GetTimeZoneOffset should return a value of -300.

But, here’s what gets returned for Winnipeg on the various devices I have at my disposal:

Device FL 1.1 FL 2.0 FL 2.1
Nokia E65 300 n/a -300
Nokia 5300 n/a -300 n/a
Nokia 6620 n/a 300 n/a

‘n/a’ means that version of Flash Lite was not tested on that device. In most cases, that version is simply not available on that device. While the 6620 can run FL 1.1, I don’t have it installed and didn’t bother installing it to test this.

(I also tested this on a Nokia 6131, a series 40 device with FL 1.1 pre-installed. It doesn’t seem to support GetTimeZoneOffset at all, so there’s no value in including it in this test. In fact, not supporting GetTimeZoneOffset at all would be preferable to buggy support. GetTimeZoneOffset fails in an interesting way on the 6131: the command appears to return nothing at all. Normally, fscommand2 arguments will return -1 if they’re not supported. Returning nothing means it’s necessary to test not just for -1 if you want to see if an fscommand2 is supported.)

Using the UTC time zone offset to calculate the time in another time zone is admittedly not foolproof: it assumes that the user has set the time zone on their device properly to correspond to their actual local time. Nevertheless, it seems that GetTimeZoneOffset is only reliable on newer devices that run at least FL 2.0.

(Note: you can use the Date object if you’re coding in FL 2.x. But the Date object is not supported in FL 1.1, so if you want to support both 1.1 and 2.x devices, that means using GetTimeZoneOffset.)

(Note2: this post has been edited to correct some time zone mistakes I made in the original post.)