aqDateTime.SetTimeElements Method

Applies to TestComplete 15.0, last modified on November 17, 2021

Description

Use the aqDateTime.SetTimeElements method to create a Date value with the specified hour, minute and second. The resulting value contains only the time portion. To specify both the date and time elements, use the SetDateTimeElements method. To specify only the date portion, use the SetDateElements method.

Declaration

aqDateTime.SetTimeElements(Hour, Min, Sec)

Hour [in]    Required    Integer    
Min [in]    Required    Integer    
Sec [in]    Required    Integer    
Result Date/Time

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Hour

Specifies the desired hour.

Min

Specifies the desired minute.

Sec

Specifies the desired second.

Result Value

A Date/Time value that holds the specified time.

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
SetDateElements Method
SetDateTimeElements Method
Now Method
Today Method
Time Method

Highlight search results