Forum Discussion

david_taylor's avatar
david_taylor
New Contributor
10 years ago
Solved

Options to store the actual date before the system date is set to another date

Hi

I am using TestComplete 10 with a DeskTop module.  I have some scripts that use aqDateTime to change the system date.

I want the tests to set the system date back to the actual date at the end, but I am not sure the best approach for this.



eg.


  1. Todays actual date is 22/10/2014


  2. System date is changed to 09/09/2002


  3. System date is changed back to the actual date (22/10/2014)




I have looked at setting a temporary project variable value that gets the date before it is changed by a test, however that requires a script to be run to set the value.  I really wanted the value set before any test or script is executed.

 

Is it worth persuing a way to do this through variables, or is there another way this can be done (ie getting the actual date from the internet)
  • Hi David,



    You may implement the code that gets the current date/time and stores it into the temporary project variable in the OnStartTest event handler. This will guarantee that you will not need to execute some separate test code to have the variable to be populated with the value.

3 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Scott,



    I also don't know it for sure, but I would keep "net stop "Windows Time" to be on the safe side.

    If you are in the domain, you may consult with your system administrator and ask him how can you prevent the system to synchronize the time with the domain controller.
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi David,



    You may implement the code that gets the current date/time and stores it into the temporary project variable in the OnStartTest event handler. This will guarantee that you will not need to execute some separate test code to have the variable to be populated with the value.
  • This is a topic I was looking into recently.  Does anyone know if the Windows Time service is supposed to reset the date if it is set by aqDateTime? 



    I'm currently building a process to change the date, but before I change it I "net stop "Windows Time" to keep windows from "correcting" my date choice for me.  I'm not sure if this is necessary, and I did not see anything in the documentation about it.