View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0003140||3 - Current Dev List||Bug||public||2019-01-30 20:43||2019-02-01 14:33|
|Target Version||Fixed in Version||220.127.116.11|
|Summary||0003140: SystemTimeTotimet() copy-paste function is broken|
|Description||There's a SystemTimeTotimet() function floating around the code base which has a bogus implemnetation. It converts the time represented by a Windows SYSTEMTIME structure to a CRTL time_t value. |
It's meant to initialize a struct tm, then give that to mktime(), and use the resulting time_t value. But it doesn't work correctly; it fails to initialize the tm's is_dst field. The structure is held on the stack, so the value is random. Which means the result is off by an hour randomly.
The function is used to convert local time to UTC (or back), and will adversely affect the reuslts of such a computation at random. The algorithm (more copy pasta in its implementation) is to call the Windows GetSystemTime() API, then the GetLocalTime() API, convert the values to time_t, and then subtract the difference.
Statistically, the values will be correct half the time (+0 +0 corect, and +1 +1 compensating errors). But since the calling locations introduce bias in how they used the previous stack space entries, then the results have some deterministic factor and might not be completely random.
The subtraction algorithm is absurd, anyway. If there's a clock tick between the Windows get time calls, the difference won't be an exact amount -- off by a second or even two.
A correct implementation calls the Windows GetTimeZoneInformation API and uses the time zone bias value it returns, directly, without any computation or conversion.
|Steps To Reproduce||Review the code|
|Additional Information||Satellite Tracker and Logbook contain copies of this|
|Tags||No tags attached.|
|related to||0001564||closed||WA9PIE||3 - Current Dev List||Line in "Next Passes" no longer follows the satellite across the horizon|
|related to||0003090||closed||K7ZCZ||3 - Current Dev List||Time shown below each of the passes in the "Next Passes" pane are off by 60 minutes late|
|related to||0002958||new||1 - Backlog||Spotted stations not appearing in Bandmap|
fixed with this checkin:
Tweaked with this checkin:
I'm going to say this is fixed and is validated.
That did change things a bit for 3090, but makes them easier to replicate (in my opinion).
Now the problem is 3090 where the graph is always showing local time in 24 hr format when it should follow what's been selected in time format (as it does above the graph). I've added notes to 3090.
This code was treating the bias as minutes; I've fixed it to convert to seconds as necessary. Done in this checkin:
|2019-01-30 20:43||K7ZCZ||New Issue|
|2019-01-30 20:44||K7ZCZ||Relationship added||related to 0003090|
|2019-01-30 22:15||K7ZCZ||Relationship added||related to 0002958|
|2019-01-30 23:06||K7ZCZ||Assigned To||=> K7ZCZ|
|2019-01-30 23:06||K7ZCZ||Status||new => resolved|
|2019-01-30 23:06||K7ZCZ||Resolution||open => fixed|
|2019-01-30 23:06||K7ZCZ||Note Added: 0007176|
|2019-01-30 23:14||WA9PIE||Relationship deleted||related to 0002958|
|2019-01-30 23:14||WA9PIE||Relationship added||related to 0001564|
|2019-01-31 08:39||K7ZCZ||Note Added: 0007179|
|2019-01-31 15:16||K7ZCZ||Relationship added||related to 0002958|
|2019-01-31 23:06||WA9PIE||Status||resolved => closed|
|2019-01-31 23:06||WA9PIE||Fixed in Version||=> 18.104.22.168|
|2019-01-31 23:06||WA9PIE||Summary||SystemTimeTotimet() copy-pasta function is broken => SystemTimeTotimet() copy-paste function is broken|
|2019-01-31 23:06||WA9PIE||Description Updated||View Revisions|
|2019-01-31 23:06||WA9PIE||Testing||Not Started => Beta Successful|
|2019-01-31 23:06||WA9PIE||Note Added: 0007187|
|2019-02-01 14:33||K7ZCZ||Note Added: 0007202|