TestComplete Tip: How To Set Windows System Time
Have you tested to see what happens to your application when the clock turns to midnight? How about when a new year starts?
You can change the system time and simulate the passage of time to give your app a workout.
Eric Holton and Martin Ouellette recently gave good examples of how to set the Windows system time in TestComplete.
Here's Eric's code:
And here's Martin's example:
After you change the time and run your test you should reset the system time. Normally Windows will check the time server and synchronize only every eight hours.
You can force a reset by stopping and re-starting the service "Windows Time" to get Windows to contact the time server and synchronize the time to the configured server time. Here's the command-line way to stop and start the time service:
net stop "Windows Time"
net start "Windows Time"
You can add that to your script using the command-line launch technique described here.
It can take time to reset the time, so you should set the date to a time in the far past and then check the date to verify that the service has received the correct time from the server.