It sometimes happens that our clients’ desktop PCs’ dates and/or times are way out (e.g. weeks ahead or behind)!
So obviously our Clarion code running under those circumstances gets incorrect values from today() and clock() - which are often used as default values on the GUIs… which users just glance over and don’t pay mush attention to, which in turn creates havoc within the logistical systems that we build and provide to our clients.
So we’ve countered this (to an extent) by checking the date/time of the on-prem SQL servers (via a simple SQL query) that our clients work with. But sometimes even our clients’ SERVERs date/time are way wrong!
So: we’re looking at having our applications obtain the correct local date and time at startup FROM A RELIABLE INTERNET SOURCE, e.g. an NTP server? And then adjust the PCs clock accordingly.
Any hints on the best way of obtaining the correct local date and time from the internet? Code examples perhaps?
Does NetTalk perhaps have a built-in function for this?
so yeah, there are time servers on the internet. You can use the NetWebClient class to make a request to any of them. For example; http://time.nist.gov:13
the NetTalk Demo app, testWebClient procedure, Atomic Time Server tab has an example of that GET and an example of parsing the string. (I suspect that parsing code could be updated now, now that we have StringTheory.)
The protocol NTP is implemented in library Catalyst Socket Tools.
I used to work with NTP and did not require a license.
A file with a description of the prototypes was created for Clarion. SocketTools
(a) does a “sanity check” directly to the “outside world” to see if the PC’s date & time is OK;
and if NOT OK
(b) warns the user that the application will not continue until the PC’s date & time is properly set (by either the application itself, or by the user).