Friday, May 16, 2008

SilkTest - TimeStamp for Current time

In Previous post, I have given the code to get TimeStamps from TSL (Winrunner) code. Now the same feature is given in Silktest (4Test) Code. It will be useful to create unique files and set the DateTime info whenever needed. Below I have given the 4Test ( Silktest scripting ) code snippet for timestamps.

4Test Code: TimeStamp for Current time



[+] public void GetCurrentDateTime(out String sDate optional, out String sTime optional,String sDateFormat null optional,String sTimeFormat null optional)
[ ] // Purpose: Current date and time are taken from the system.
[ ] DateTime dtmCurrent
[ ]
[+] if (IsNull(sDateFormat))
[ ] sDateFormat = "mm/dd/yyyy"
[+] if (IsNull (sTimeFormat))
[ ] sTimeFormat = "hh:nn:ss AM/PM"
[ ] dtmCurrent = GetDateTime ( )
[ ] sTime=FormatDateTime (dtmCurrent, sTimeFormat)
[ ] sDate=FormatDateTime (dtmCurrent, sDateFormat)
[+] String GetTimeStamp()
[ ] //Purpose: To get current time stamp in the given format
[ ] String sDate, sTime
[ ] String sTcFile
[ ] STRING sPrefix
[ ]
[ ] GetCurrentDateTime (sDate, sTime,"yyyymmdd","hhnnss" )
[ ] sPrefix = "{sDate}{sTime}"
[ ] return sPrefix

No comments: