I used to develop a function to have timestamps in all the testing tools. I have written same in Winrunner also. It will be useful to create unique files and set the dateTime info whenever needed. Below I have given the TSL (Test Script Language) code snippet for timestamps.
TSL Code: TimeStamp for Current time
#This function returns the current system time like this --> "24Jan2003_11hh_20mm_45ss"
public function GetTime() {
# w - in terms of Word
auto sDate, sTime, sDayW, sDayN, sMonthW, sMonthN, sYear, sHour, sMinute, sSecond;
auto sCurDate, sCurTime;
auto sArrDate[], sArrTime[];
auto sReturn;
sCurTime = get_time();
sCurDate = time_str(sCurTime); #returns like Mon Dec 16 16:09:56 2002
split (sCurDate, sArrDate, " ");
sDayW = sArrDate[1];
sMonthW = sArrDate[2];
sDayN = sArrDate[3];
sTime = sArrDate[4];
sYear = sArrDate[5];
split(sTime, sArrTime, ":");
sHour = sArrTime[1];
sMinute = sArrTime[2];
sSecond = sArrTime[3];
sReturn = sDayN & sMonthW & sYear & "_" & sHour & "hh_" & sMinute & "mm_" & sSecond & "ss";
return sReturn;
} #end of GetTime()
No comments:
Post a Comment