aqDateTime.SetSystemDateTime Method

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

Use the aqDateTime.SetSystemDateTime method to assign a new value to the system date and/or time.

Declaration

aqDateTime.SetSystemDateTime(NewDateTime)

NewDateTime [in]    Required    Date/Time    
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

NewDateTime

Specifies the new Date/Time value to be set.

Result Value

True if the new date/time was set successfully, and False otherwise.

Remarks

To use the aqDateTime.SetSystemDateTime method, TestComplete must be running with administrator privileges. See Using TestComplete With Administrator Privileges.

Example

The code below demonstrates how you can set a new system date and/or time.

JavaScript, JScript

function SettingNewSystemDateTime()
{
  var dt1 = aqDateTime.SetDateTimeElements(2010, 6, 22, 10, 15, 12);
  var dt2 = aqDateTime.SetDateElements(2010, 6, 22);
  var time1 = aqDateTime.SetTimeElements(10, 15, 12);

  // Set a new system date
  aqDateTime.SetSystemDateTime(dt2);
  // Set new system time
  aqDateTime.SetSystemDateTime(time1);
  // -- or --
  // Set a new system date and time using one function
  aqDateTime.SetSystemDateTime(dt1);

  // Post the current date and time to the test log
  var dt = aqDateTime.Now();
  Log.Message(dt);
}

Python

def SettingNewSystemDateTime():
  dt1 = aqDateTime.SetDateTimeElements(2010, 6, 22, 10, 15, 12)
  dt2 = aqDateTime.SetDateElements(2010, 6, 22)
  time1 = aqDateTime.SetTimeElements(10, 15, 12)
  # Set a new system date
  aqDateTime.SetSystemDateTime(dt2)
  # Set new system time
  aqDateTime.SetSystemDateTime(time1)
  # --or--
  # Set a new system date and time using one function
  aqDateTime.SetSystemDateTime(dt1)
  # Post the current date and time to the test log
  dt = aqDateTime.Now()
  Log.Message(dt)

VBScript

Sub SettingNewSystemDateTime
  Dim dt1, dt2, time1, dt

  dt1 = aqDateTime.SetDateTimeElements(2010, 6, 22, 10, 15, 12)
  dt2 = aqDateTime.SetDateElements(2010, 6, 22)
  time1 = aqDateTime.SetTimeElements(10, 15, 12)

  ' Set a new system date
  aqDateTime.SetSystemDateTime dt2
  ' Set new system time
  aqDateTime.SetSystemDateTime time1
  ' -- or --
  ' Set a new system date and time using one function
  aqDateTime.SetSystemDateTime dt1

  ' Post the current date and time to the test log
  dt = aqDateTime.Now
  Log.Message dt
End Sub

DelphiScript

procedure SettingNewSystemDateTime;
var dt1, dt2, time1, dt: OleVariant;
begin
  dt1 := aqDateTime.SetDateTimeElements(2010, 6, 22, 10, 15, 12);
  dt2 := aqDateTime.SetDateElements(2010, 6, 22);
  time1 := aqDateTime.SetTimeElements(10, 15, 12);

  // Set a new system date
  aqDateTime.SetSystemDateTime(dt2);
  // Set new system time
  aqDateTime.SetSystemDateTime(time1);
  // -- or --
  // Set a new system date and time using one function
  aqDateTime.SetSystemDateTime(dt1);

  // Post the current date and time to the test log
  dt := aqDateTime.Now;
  Log.Message(dt);
end;

C++Script, C#Script

function SettingNewSystemDateTime()
{
  var dt1 = aqDateTime["SetDateTimeElements"](2010, 6, 22, 10, 15, 12);
  var dt2 = aqDateTime["SetDateElements"](2010, 6, 22);
  var time1 = aqDateTime["SetTimeElements"](10, 15, 12);

  // Set a new system date
  aqDateTime["SetSystemDateTime"](dt2);
  // Set new system time
  aqDateTime["SetSystemDateTime"](time1);
  // -- or --
  // Set a new system date and time
  aqDateTime["SetSystemDateTime"](dt1);

  // Post the current date and time to the test log
  var dt = aqDateTime["Now"]();
  Log.Message(dt);
}

See Also

Working With Dates
Working With Time
Now Method
Today Method
Time Method

Highlight search results