Accurate time in LiveCode Windows app

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
studawg66
Posts: 25
Joined: Wed Jun 17, 2015 9:40 pm

Accurate time in LiveCode Windows app

Post by studawg66 » Tue Oct 27, 2015 3:24 pm

I have inherited an app written in RunRev that has been running as a standalone Mac OSX app for several years. For simplification, lets just say the app displays UTC time and needs to be precise (within 100ms or so). Recently we needed to port it to Windows for hardware support reasons. Easy enough. Used same source code and had Livecode make a Windows standalone app. Everything works great except that we noticed the time would drift from the time you start the app. It is "losing" approximately 2 seconds per day. Never happened on the Mac app.
After some troubleshooting I discovered that the time displayed in the app was not getting the NTP updates that the Windows system clock was receiving, meaning the app was "freewheeling" once started. So even though the Windows system clock is dead on with naval observatory time, the app is losing time.
Here is what I found, and would like some advice about:
The original code is using "get the seconds" to get the time in seconds and use that variable for some comparisons before putting it in a readable format. Example:

Code: Select all

put the seconds into NewTime
Apparently "seconds" is in sync with the Windows system clock only at app startup. You can see this by starting the app (clocks are in sync), then manually updating the Windows system clock (app does not receive this update and continues its "freewheel" count). Restarting the app syncs them back up.
In the process of discovering this, I found that the "time" function DOES receive system time updates, so I've managed a workaround that gets the date and time and converts them to seconds. Example:

Code: Select all

put the long date && the long time into NewTime
convert NewTime to seconds
So my questions are:
1) is there a cleaner way to do this? The code uses "get the seconds" in MANY more places, so before I go fix it everywhere I'd like to do it as efficiently as possible.
2) is this a known issue? I don't really know the differences in Mac (Unix) and Windows OS well enough to understand why the "get the seconds" command behaves differently between the two. It is kind of frustrating when trying to develop between the two platforms.

Would love to get your feedback! Thank you.

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Accurate time in LiveCode Windows app

Post by MaxV » Fri Oct 30, 2015 11:40 am

I suggest you to post ir to http://quality.runrev.com/
Livecode developers will hunt the bug you propose.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

studawg66
Posts: 25
Joined: Wed Jun 17, 2015 9:40 pm

Re: Accurate time in LiveCode Windows app

Post by studawg66 » Tue Nov 03, 2015 6:47 pm

Bug submitted and confirmed by development team. Thanks!
Bug 16340

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”