aqConvert.TimeIntervalToStr Method

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

Description

Use this method to convert the time period value returned by the aqDateTime.TimeInterval method to a string. The TimeInterval method returns the absolute difference between two specified date/time values, at that, the method's result is also a date/time value denoting the time that has passed since the "zero date", which is 12:00 AM December 30, 1899.

The TimeIntervalToStr method accepts a date/time value and generates a formatted string indicating the number of days, hours, minutes and seconds that have passed since the "zero date".

Declaration

aqConvert.TimeIntervalToStr(Interval)

Interval [in]    Required    Date/Time    
Result String

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Interval

Specifies a date/time value denoting a time extent.

Result Value

A string in the D:HH:MM:SS format that describes the time interval.

Where D corresponds to the number of days passed, HH - to the number of passed hours, MM - to the number of passed minutes, and SS - to the number of passed seconds. The number of hours, minutes and seconds is displayed as two digits with a leading zero when required. The number of days is displayed as one or more digits. If the time interval is less than one day, a zero stands for the number of days.

Example

The code below demonstrates how you can use the TimeIntervalToStr method in your scripts:

JavaScript, JScript

function TimeIntervalDemo()
{
  var Time1 = aqDateTime.Time();
  var Time2 = aqDateTime.AddTime(Time1,1,0,0,5);
  var Difference = aqDateTime.TimeInterval(Time1, Time2);
  Log.Message("The interval as DateTime: " + aqConvert.DateTimeToStr(Difference));
  // Posts "The interval as DateTime: 12/31/1899 12:00:05 AM"
  Log.Message("The interval in Days:Hours:Minutes:Seconds format: " + aqConvert.TimeIntervalToStr (Difference));
  // Posts "The interval in Days:Hours:Minutes:Seconds format: 1:00:00:05"
}

Python

def TimeIntervalDemo():
  Time1 = aqDateTime.Time()
  Time2 = aqDateTime.AddTime(Time1,1,0,0,5)
  Difference = aqDateTime.TimeInterval(Time1, Time2)
  Log.Message("The interval as DateTime: " + aqConvert.DateTimeToStr(Difference))
  # Posts "The interval as DateTime: 12/31/1899 12:00:05 AM"
  Log.Message("The interval in Days:Hours:Minutes:Seconds format: " + aqConvert.TimeIntervalToStr (Difference))
  # Posts "The interval in Days:Hours:Minutes:Seconds format: 1:00:00:05"

VBScript

Sub TimeIntervalDemo
Dim Time1, Time2, Difference
  Time1 = aqDateTime.Time()
  Time2 = aqDateTime.AddTime(Time1,1,0,0,5)
  Difference = aqDateTime.TimeInterval(Time1, Time2)
  Log.Message("The interval as DateTime: " + aqConvert.DateTimeToStr(Difference))
  ' Posts "The interval as DateTime: 12/31/1899 12:00:05 AM"
  Log.Message("The interval in Days:Hours:Minutes:Seconds format: " + aqConvert.TimeIntervalToStr (Difference))
  ' Posts "The interval in Days:Hours:Minutes:Seconds format: 1:00:00:05"
End Sub

DelphiScript

procedure TimeIntervalDemo;
var Time1, Time2, Difference;
begin
  Time1 := aqDateTime.Time();
  Time2 := aqDateTime.AddTime(Time1,1,0,0,5);
  Difference := aqDateTime.TimeInterval(Time1, Time2);
  Log.Message('The interval as DateTime: ' + aqConvert.DateTimeToStr(Difference));
  // Posts "The interval as DateTime: 12/31/1899 12:00:05 AM"
  Log.Message('The interval in Days:Hours:Minutes:Seconds format: ' + aqConvert.TimeIntervalToStr (Difference));
  // Posts "The interval in Days:Hours:Minutes:Seconds format: 1:00:00:05"
end;

C++Script, C#Script

function TimeIntervalDemo()
{
  var Time1 = aqDateTime["Time"]();
  var Time2 = aqDateTime["AddTime"](Time1,1,0,0,5);
  var Difference = aqDateTime["TimeInterval"](Time1, Time2);
  Log["Message"]("The interval as DateTime: " + aqConvert["DateTimeToStr"](Difference));
  // Posts "The interval as DateTime: 12/31/1899 12:00:05 AM"
  Log["Message"]("The interval in Days:Hours:Minutes:Seconds format: " + aqConvert["TimeIntervalToStr"](Difference));
  // Posts "The interval in Days:Hours:Minutes:Seconds format: 1:00:00:05"
}

See Also

Working With Dates
Working With Time
aqDateTime Object
TimeInterval Method

Highlight search results