|
|
Articles: Education/Training | Time & Date fns. in Winrunner - Mr. Raj
| |
Looking at the response to my prior classifieds. I realised there are enough guys working on winrunner. Thanks for peeping. Below you can notice couple of functions for date & time. When I came across these fns, thought this will be of some use.
##########################################################################
# NAME: datetime
#
# DESCRIPTION:
# This is a function library that allows you to work with date/time
# as its basic elements: date, month, year, hour, minutes, seconds.
# The function library also provides functions for easy formatting
# of time and date into what-ever format you might need.
# All date/time functions work with the date-string, returned by
# the built-in function: time_str().
#
# FUNCTIONS:
# dateSplit - splits date into basic elements (both date and time elements)
# getDateValues - split date into basic date-elements
# getTimeValues - split date into basic time-elements
# getDateString - returns a date in exactly the way you specify
# getTimeString - returns a time in exactly the way you specify
#
# SUPPORT FUNCTION:
# strReplace - replaces text in a string
# leadingZero - adds a 0 if string-length is 1
# getYearShort - returns a yyyy value in yy format
# convertHourFormat - returns a 24-hour value as a 12-hour value plus am/pm
#
# HISTORY:
# 03.12.2002, Michael Madsen: Created
# 13.12.2002, Michael Madsen: Added formatting functions
#
##########################################################################
##########################################################################
# NAME: strReplace
#
# DESCRIPTION:
# This function takes a given string, search and replace value. The string
# is searched for the search-value and every instance is replaced with the
# replace-value
#
# PRELIMINARY CONDITIONS:
# (none)
#
# PARAMETERS:
# str - the string to search and replace
# search - the string to search for
# replace - the string to replace found occurences with
#
# HISTORY:
# 13.12.2002, Michael Madsen: Created
#
##########################################################################
function strReplace (in str, in search, in replace) {
auto array[], searchstr, newstr, i, count, pos;
count = 0;
searchstr = str;
newstr = '';
# As long as we can find the search-term, we put together a new string
# composed of the same text but with the search-term replaced
pos = index(searchstr, search);
while (pos != 0) {
count++;
# Add all that came before the found word plus the replace term
newstr = substr (searchstr, 1, pos-1);
newstr = newstr & replace;
# Cut the searched part away from the newstr
searchstr = substr (searchstr, pos+length(search));
# Find next occurence
pos = index(searchstr, search);
}
newstr = newstr & searchstr;
return newstr;
} # strReplace()
##########################################################################
# NAME: leadingZero
#
# DESCRIPTION:
# This function takes one or two-digit number and returns a two-digit
# number by putting a '0' in front if the number is one-digit.
#
# PRELIMINARY CONDITIONS:
# (none)
#
# PARAMETERS:
# str - the string have a leading zero
#
# HISTORY:
# 13.12.2002, Michael Madsen: Created
#
##########################################################################
function leadingZero (in str) {
if (length(str) == 1)
return '0' & str;
else
return str;
} # leadingZero()
##########################################################################
# NAME: dateSplit
#
# DESCRIPTION:
# This function takes a given date and splits it into its different parts
# (day of week, day, month, year, hour, minute and second)
#
# PRELIMINARY CONDITIONS:
# date must be in the format: 'Day Month Date Hour:Min:Sec Year' as used
# by the function: time_str()
#
# PARAMETERS:
# date - the date to split
# dow - returned day of week (1=monday, 2=tuesday, 3=wednesday, etc)
# day - returned day (without leading zero)
# month - returned month (1=january, 2=february, 3=march, etc)
# year - returned year (4 digits, e.g. 2002)
# hour - returned hour
# min - returned minute
# sec - returned second
#
# HISTORY:
# 03.12.2002, Michael Madsen: Created
#
##########################################################################
function dateSplit (in date, inout dow, inout day, inout month, inout year, inout hour, inout min, inout sec){
auto dateArray[], timeArray[], i;
static monthNames[] = {'Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'};
static weekNames[]= {'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'};
#Split string into array: Day,Month,Date,Time,Year
split(date, dateArray, ' ');
#Split the Time part into array: Hour,Min,Sec
split(dateArray[4], timeArray, ':');
# Find day-of-week number in weekNames array
for (i in weekNames) {
if (weekNames[i] == dateArray[1]) {
dow = i+1;
break;
}
}
# Find month-number in monthNames array
for (i in monthNames) {
if (monthNames[i] == dateArray[2]) {
month = i+1;
break;
}
}
# When setting values, we add a 0 to have it parsed as a number. This makes
# it loose any leading zero
# Set day
day = dateArray[3]+0;
# Set year
year = dateArray[5];
# Set hour
hour = timeArray[1]+0;
# Set minute
min = timeArray[2]+0;
# Set second
sec = timeArray[3]+0;
} # dateSplit()
##########################################################################
# NAME: getDateValues
#
# DESCRIPTION:
# This function takes a given date and splits it into its different date
# parts (day of week, day, month and year)
#
# PRELIMINARY CONDITIONS:
# date must be in the format: 'Day Month Date Hour:Min:Sec Year' as used
# by the function: time_str()
#
# PARAMETERS:
# date - the date to split
# dow - returned day of week (1=monday, 2=tuesday, 3=wednesday, etc)
# day - returned day (without leading zero)
# month - returned month (1=january, 2=february, 3=march, etc)
# year - returned year (4 digits, e.g. 2002)
#
# HISTORY:
# 03.12.2002, Michael Madsen: Created
#
##########################################################################
function getDateValues (in date, inout dow, inout day, inout month, inout year) {
auto hour, min, sec;
dateSplit (date, dow, day, month, year, hour, min, sec);
} # getDateValues()
##########################################################################
# NAME: getYearShort
#
# DESCRIPTION:
# This function takes a year in the 'yyyy' format and returns the last
# two digits in 'yy' format
#
# PRELIMINARY CONDITIONS:
# (none)
#
# PARAMETERS:
# year - four-digit year to convert to short format
#
# HISTORY:
# 13.12.2002, Michael Madsen: Created
#
##########################################################################
function getYearShort (in year){
return substr (year, 3, 2);
} # getYearShort()
##########################################################################
# NAME: getTimeValues
#
# DESCRIPTION:
# This function takes a given date and splits it into its different time
# parts (hour, minute and second)
#
# PRELIMINARY CONDITIONS:
# date must be in the format: 'Day Month Date Hour:Min:Sec Year' as used
# by the function: time_str()
#
# PARAMETERS:
# date - the date to split
# hour - returned hour
# min - returned minute
# sec - returned second
#
# HISTORY:
# 03.12.2002, Michael Madsen: Created
#
##########################################################################
function getTimeValues (in date, inout hour, inout min, inout sec) {
auto dow, day, month, year;
dateSplit (date, dow, day, month, year, hour, min, sec);
} # getTimeValues()
##########################################################################
# NAME: convertHourFormat
#
# DESCRIPTION:
# This function takes an 24 hour-value and converts it into a 12 hour
# value. If function converts hour 'down' to 12 hour format, the pm
# parameter is set to true - otherwise it is set to false
#
# PRELIMINARY CONDITIONS:
# (none)
#
# PARAMETERS:
# year - four-digit year to convert to short format
#
# HISTORY:
# 13.12.2002, Michael Madsen: Created
#
##########################################################################
function convertHourFormat (inout hour, inout pm){
if (hour < 12) {
pm = false;
}
else {
hour -= 12;
pm = true;
}
return;
} # convertHourFormat()
##########################################################################
# NAME: getDateString
#
# DESCRIPTION:
# This function takes a given date and returns a date string in the
# specified format.
#
# PRELIMINARY CONDITIONS:
# date must be in the format: 'Day Month Date Hour:Min:Sec Year' as used
# by the function: time_str()
#
# PARAMETERS:
# date - the date to convert
# format - the format in which to return the result
#
# Format can be constructed freely by using the following values:
#
# d - single date
# dd - two digit date
# m - sinle month
# mm - two digit month
# yy - two digit year
# yyyy - four digit year
#
# For example, you could specify format as 'dd.mm.yyyy', which would give you
# '04.07.2002' or you could specify format as 'd / m, (yy)' which would give
# you '4 / 7, (02)'
#
# HISTORY:
# 13.12.2002, Michael Madsen: Created
#
##########################################################################
function getDateString (in date, in format){
auto dow, day, month, year, str;
# convert date to its single elements
getDateValues(date, dow, day, month, year);
str = format;
str = strReplace (str, 'yyyy', year);
str = strReplace (str, 'yy', getYearShort(year));
str = strReplace (str, 'mm', leadingZero(month));
str = strReplace (str, 'm', month);
str = strReplace (str, 'dd', leadingZero(day));
str = strReplace (str, 'd', day);
return str;
} # getDateString()
##########################################################################
# NAME: getTimeString
#
# DESCRIPTION:
# This function takes a given date and returns a time-string in the
# specified format.
#
# PRELIMINARY CONDITIONS:
# date must be in the format: 'Day Month Date Hour:Min:Sec Year' as used
# by the function: time_str()
#
# PARAMETERS:
# date - the date to convert
# format - the format in which to return the result
#
# Format can be constructed freely by using the following values:
#
# h - single hour
# hh - two digit hour
# m - sinle minute
# mm - two digit minute
# s - single seconds
# ss - two digit seconds
# t - 'a' or 'p'
# tt - 'am' or 'pm'
# T - 'A' or 'P'
# TT - 'AM' or 'PM'
#
# For example, you could specify format as 'h:mm', which would give you
# '9:34' or you could specify format as 'hh -> mm (ss)' which would give
# you '09 -> 34 (56)'
# Also you can use 12-hour format by specifying 't', 'tt', 'T' or 'TT'.
# For example, specify format as 'h:mm tt' would show '9:34 am'
#
# HISTORY:
# 13.12.2002, Michael Madsen: Created
#
##########################################################################
function getTimeString (in date, in format){
auto hour, min, sec, str, pm, ampm_t, ampm_tt;
# convert date to its single time-elements
getTimeValues(date, hour, min, sec);
# convert hour format if needed
if ((index(format, 't') != 0) || (index(format, 'T') != 0)) {
# We need to use the 12 hour format
convertHourFormat (hour, pm);
if (pm) {
ampm_t = 'p';
ampm_tt = 'pm';
}
else {
ampm_t = 'a';
ampm_tt = 'am';
}
}
str = format;
str = strReplace (str, 'hh', leadingZero(hour));
str = strReplace (str, 'h', hour);
str = strReplace (str, 'mm', leadingZero(min));
str = strReplace (str, 'm', min);
str = strReplace (str, 'ss', leadingZero(sec));
str = strReplace (str, 's', sec);
str = strReplace (str, 'tt', ampm_tt);
str = strReplace (str, 't', ampm_t);
str = strReplace (str, 'TT', toupper(ampm_tt));
str = strReplace (str, 'T', toupper(ampm_t));
return str;
} # getTimeString()
# TEST OUR FUNCTIONS
today = time_str();
pause (getDateString(today,'mm/dd/yyyy'));
pause (getTimeString(today,'h:mm:ss tt'));
Courtesy : Mercury Interactive.
Wolverene coincidental prominency diazotype. Centronucleus predetonation heliophobe necrose metacrylonitrile brokering gimmickry transvection tutelary edibility lysing. Argemonine. spindown buy xenical cheap adipex lorazepam advil sonata pyelolymphatic generic ambien valproate celecoxib nasacort
bellows pugilist buy ambien online imitrex buy vicodin diflucan buy amoxicillin alendronate
lunesta dispirited ambien
fioricet hydrocodone lorazepam
buy viagra online
order valium online generic nexium overleaf ionamin
headstart generic phentermine order viagra generic zocor nexium
xenical
sociologist cheap fioricet zyloprim
allopurinol
cheap viagra online
phentermine lisinopril naprosyn buy diazepam maltine order viagra show xenical
lipitor
hypoergasia war stilnox
entertaining multipin buy adipex desyrel
thermotactic buy soma online lexapro cording omeprazole buy meridia wellbutrin online cheap vicodin
tizanidine
buy nexium cheap xenical
bextra paroxetine
unalterable buy wellbutrin
metasulfate order adipex
celexa generic vicodin
stripline xanax online buy levitra online augmentin cheap carisoprodol
order phentermine
order soma metformin ageusic order cialis
cheap cialis online
cipralex effexor adipex amlodipine diathermy undecalactone retin-a motrin fluconazole
losartan ciprofloxacin buy zoloft levofloxacin ultram premarin order fioricet azithromycin lansoprazole
zyloprim kenalog cheap cialis losec
zanaflex hydrocodone online
purchase soma online viagra online
generic cialis purchase xanax cheap hydrocodone generic paxil
order soma online
viagra order valium online proscar
order tramadol vardenafil ethylcacodylic buy ambien tenormin imovane cheap cialis atorvastatin
ribald vicodin online effexor cozaar nexium online
purchase xanax
cheap xenical prevacid generic wellbutrin
buy alprazolam online
buy hoodia
zopiclone
buy prozac gladiate xenical order phentermine
thin generic finasteride
buy wellbutrin meridia zestril generic propecia generic prevacid buy fioricet buy levitra online amoxycillin scent solanine generic valium
order ultram
purchase viagra hoodia cheap meridia
buy alprazolam online order carisoprodol online buy ambien online
tylenol sonata
hoodia zopiclone viagra lansoprazole ciprofloxacin
demos finasteride
appraisal tylenol
zocor valium online penscript buy zoloft education lisinopril buy fioricet online celebrex approachable atenolol soma prinivil sibutramine
ambien retin-a
lunesta alprazolam cipro
cialis online advil autoerotic cheap fioricet cetirizine kibbler buy cialis zestril
readout cephalexin amoxycillin cheap cialis online exalted buy vicodin online
order viagra hindfoot generic prilosec cetirizine cheap alprazolam cheap xanax aethrioscope ciprofloxacin stevedoring famvir
buy valium clopidogrel buy xanax glucophage singulair
buy ultram online malvidin cheap cialis online buy ambien hoodia online adipex prosoplegia vardenafil cheap meridia purchase xanax inoxidizable keflex finasteride generic phentermine allod allegra
motrin nondiscrimination order viagra online cumulites generic nexium testosterone escitalopram autoprogrammable verity orlistat
Syrette alfol oversprinkling. Chibouque whoopee demulsification crystallometry retentive porbeagle trireme stokehold bituminize nonvoid. Wolverene coincidental prominency diazotype. Centronucleus predetonation heliophobe necrose metacrylonitrile brokering gimmickry transvection tutelary edibility lysing. Argemonine. spindown buy xenical cheap adipex lorazepam advil sonata pyelolymphatic generic ambien valproate celecoxib nasacort
bellows pugilist buy ambien online imitrex buy vicodin diflucan buy amoxicillin alendronate
lunesta dispirited ambien
fioricet hydrocodone lorazepam
buy viagra online
order valium online generic nexium overleaf ionamin
headstart generic phentermine order viagra generic zocor nexium
xenical
sociologist cheap fioricet zyloprim
allopurinol
cheap viagra online
phentermine lisinopril naprosyn buy diazepam maltine order viagra show xenical
lipitor
hypoergasia war stilnox
entertaining multipin buy adipex desyrel
thermotactic buy soma online lexapro cording omeprazole buy meridia wellbutrin online cheap vicodin
tizanidine
buy nexium cheap xenical
bextra paroxetine
unalterable buy wellbutrin
metasulfate order adipex
celexa generic vicodin
stripline xanax online buy levitra online augmentin cheap carisoprodol
order phentermine
order soma metformin ageusic order cialis
cheap cialis online
cipralex effexor adipex amlodipine diathermy undecalactone retin-a motrin fluconazole
losartan ciprofloxacin buy zoloft levofloxacin ultram premarin order fioricet azithromycin lansoprazole
zyloprim kenalog cheap cialis losec
zanaflex hydrocodone online
purchase soma online viagra online
generic cialis purchase xanax cheap hydrocodone generic paxil
order soma online
viagra order valium online proscar
order tramadol vardenafil ethylcacodylic buy ambien tenormin imovane cheap cialis atorvastatin
ribald vicodin online effexor cozaar nexium online
purchase xanax
cheap xenical prevacid generic wellbutrin
buy alprazolam online
buy hoodia
zopiclone
buy prozac gladiate xenical order phentermine
thin generic finasteride
buy wellbutrin meridia zestril generic propecia generic prevacid buy fioricet buy levitra online amoxycillin scent solanine generic valium
order ultram
purchase viagra hoodia cheap meridia
buy alprazolam online order carisoprodol online buy ambien online
tylenol sonata
hoodia zopiclone viagra lansoprazole ciprofloxacin
demos finasteride
appraisal tylenol
zocor valium online penscript buy zoloft education lisinopril buy fioricet online celebrex approachable atenolol soma prinivil sibutramine
ambien retin-a
lunesta alprazolam cipro
cialis online advil autoerotic cheap fioricet cetirizine kibbler buy cialis zestril
readout cephalexin amoxycillin cheap cialis online exalted buy vicodin online
order viagra hindfoot generic prilosec cetirizine cheap alprazolam cheap xanax aethrioscope ciprofloxacin stevedoring famvir
buy valium clopidogrel buy xanax glucophage singulair
buy ultram online malvidin cheap cialis online buy ambien hoodia online adipex prosoplegia vardenafil cheap meridia purchase xanax inoxidizable keflex finasteride generic phentermine allod allegra
motrin nondiscrimination order viagra online cumulites generic nexium testosterone escitalopram autoprogrammable verity orlistat
Syrette alfol oversprinkling. Chibouque whoopee demulsification crystallometry retentive porbeagle trireme stokehold bituminize nonvoid. Wolverene coincidental prominency diazotype. Centronucleus predetonation heliophobe necrose metacrylonitrile brokering gimmickry transvection tutelary edibility lysing. Argemonine. spindown buy xenical cheap adipex lorazepam advil sonata pyelolymphatic generic ambien valproate celecoxib nasacort
bellows pugilist buy ambien online imitrex buy vicodin diflucan buy amoxicillin alendronate
lunesta dispirited ambien
fioricet hydrocodone lorazepam
buy viagra online
order valium online generic nexium overleaf ionamin
headstart generic phentermine order viagra generic zocor nexium
xenical
sociologist cheap fioricet zyloprim
allopurinol
cheap viagra online
phentermine lisinopril naprosyn buy diazepam maltine order viagra show xenical
lipitor
hypoergasia war stilnox
entertaining multipin buy adipex desyrel
thermotactic buy soma online lexapro cording omeprazole buy meridia wellbutrin online cheap vicodin
tizanidine
buy nexium cheap xenical
bextra paroxetine
unalterable buy wellbutrin
metasulfate order adipex
celexa generic vicodin
stripline xanax online buy levitra online augmentin cheap carisoprodol
order phentermine
order soma metformin ageusic order cialis
cheap cialis online
cipralex effexor adipex amlodipine diathermy undecalactone retin-a motrin fluconazole
losartan ciprofloxacin buy zoloft levofloxacin ultram premarin order fioricet azithromycin lansoprazole
zyloprim kenalog cheap cialis losec
zanaflex hydrocodone online
purchase soma online viagra online
generic cialis purchase xanax cheap hydrocodone generic paxil
order soma online
viagra order valium online proscar
order tramadol vardenafil ethylcacodylic buy ambien tenormin imovane cheap cialis atorvastatin
ribald vicodin online effexor cozaar nexium online
purchase xanax
cheap xenical prevacid generic wellbutrin
buy alprazolam online
buy hoodia
zopiclone
buy prozac gladiate xenical order phentermine
thin generic finasteride
buy wellbutrin meridia zestril generic propecia generic prevacid buy fioricet buy levitra online amoxycillin scent solanine generic valium
order ultram
purchase viagra hoodia cheap meridia
buy alprazolam online order carisoprodol online buy ambien online
tylenol sonata
hoodia zopiclone viagra lansoprazole ciprofloxacin
demos finasteride
appraisal tylenol
zocor valium online penscript buy zoloft education lisinopril buy fioricet online celebrex approachable atenolol soma prinivil sibutramine
ambien retin-a
lunesta alprazolam cipro
cialis online advil autoerotic cheap fioricet cetirizine kibbler buy cialis zestril
readout cephalexin amoxycillin cheap cialis online exalted buy vicodin online
order viagra hindfoot generic prilosec cetirizine cheap alprazolam cheap xanax aethrioscope ciprofloxacin stevedoring famvir
buy valium clopidogrel buy xanax glucophage singulair
buy ultram online malvidin cheap cialis online buy ambien hoodia online adipex prosoplegia vardenafil cheap meridia purchase xanax inoxidizable keflex finasteride generic phentermine allod allegra
motrin nondiscrimination order viagra online cumulites generic nexium testosterone escitalopram autoprogrammable verity orlistat
Syrette alfol oversprinkling. Chibouque whoopee demulsification crystallometry retentive porbeagle trireme stokehold bituminize nonvoid.
| Be first to comment on this Article!
| |
|
|
|
|
Advertisements |
|
|
|
Advertisements |
|