Forum Discussion

diegof's avatar
diegof
New Contributor
8 years ago

System date actualization

Hi all,

 

I have an issue to modify System Date time.  I need to modify for a scripts section, the Windows date. I could do it, but i need after this script section, to return at real time.

 

For example, if i need to set Today on system, I used a boolean True and if False, a hardcode date. First I hardcode the date and then i should set the real time date.

 

sub DateSystem(Today)

 

If Today = true then
   aqdatetime.SetSystemDateTime(aqdatetime.Now)
   Log.Message "System date is: " & aqdatetime.Today
else

  day = aqDateTime.SetDateElements("2017", "05", "22")
  aqDateTime.SetSystemDateTime day
  Log.Message "System date is: " & aqdatetime.Today
End if

end sub

 

How can I return the System date to normal or real date/time?

 

Regards.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    What I would do is, before you set the date and time to your previous date, store the current date/time in some variable.  That way, you can always restore it when you need to.

    • diegof's avatar
      diegof
      New Contributor

      I think about that, but the time that I can store would not be the same that the real time on that moment, because the scripts in the middle of the 2 date changes (first date harcode then actual date) take some time that I cannot get.



       

       

       

       

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        What you might need to do, then, is grab the time portion and concatenate/add that to the stored date time for the current date.

         

        Basically:

         

        store aqDateTime.Today()

        Change to new date time

        check for date time change

        add stored date to current aqDateTime.Time()

        Change to the restored date