Overview
Catchpoint supports injecting dynamic content into scripts, the test URL field for web tests, header overrides, alert emails, and alert webhook templates.
ParseTime()
This is a sub-macro of the DateTime() macro which performs a datetime conversion on the input string and outputs a re-formatted datetime string.
If no parameter is specified, the output format will be YYYYMMDDHHMISS. The input parameter should be a standard date-time format, or of the YYYY{MM{DD{HH{MI{SS{MSC}}}}}} format.
Example
open("https://www.catchpoint.com")
storeVariable("${Extract('resp-headers', 'regexp:date:(.*)', parseTime())}", "timestamp")
open("http://www.google.com/?${var(timestamp)}")
The above code extracts the date response header and then parse it.


timeDiff()
The timeDiff() macro compares two DateTime strings.
Here is the format for the timeDiff() macro:
${timeDiff('${var(t1)}', '${var(t2)}', 'format', 'trim-flag')}
- The first two parameters are expected to be in YYYYMMDD{HH{MI{SS{MSC}}}} format.
- The third parameter has the formats listed below (defaults to st).
- The fourth parameter indicates whether to prevent zero-padding or not (defaults to false).
Format options for the 3rd parameter:
- dd - day of month (no zero padding)
- hh - hour (by 24-hour clock. trimming allowed. defaults to 2-digit hour)
- ht - total hours (no zero padding)
- mi - minute (trimming allowed, defaults to 2-digit minute)
- mit - total minutes (no zero padding)
- ms - milliseconds (trimming allowed, defaults to 3-digit millisecond)
- mst - total milliseconds (no zero padding)
- ss - seconds (trimming allowed, defaults to 2-digit second)
- st - total seconds (no zero padding)
Any other characters will show up as entered in the output of the macro.
Examples:
var a = 20141121113945078;
var b = 20141121;
var c = ${timediff("${var(a)}", "${var(b)}")};
var d = ${timediff("${var(a)}", "${var(b)}", "ss.ms")};
var e = ${timediff("${var(a)}", "${var(b)}", "mst")};
var f = ${timediff("${var(a)}", "${var(b)}", "dd:hh:mi:ss.ms")};
var g = ${timediff("${var(a)}", "${var(b)}", "ms")};
var h = ${timediff("${var(a)}", "${var(b)}", "ms", "true")};
open(http://www.google.com/a=${var(a)}/b=${var(b)}/c=${var(c)}/d=${var(d)}/e=${var(e)}/f=${var(f)}/g=${var(g)}/h=${var(h)})
assert(${extract('url','regexp:^(.+)$','eq(http://www.google.com/a=20141121113945078/b=20141121/c=41985/d=45.078/e=41985078/f=0:11:39:45.078/g=078/h=78)')})
Here is a script to illustrate the usage of both parseTime() and timeDiff().
open("https://www.catchpoint.com")
storeVariable("${Extract('resp-headers', 'regexp:date:(.*)', parseTime())}", "timestamp")
open("http://www.google.com/?${var(timestamp)}")
var diff = ${timediff("${var(timestamp)}","${time}","dd:hh:mi:ss:ms")};
open("http://www.google.com/?d=${var(diff)}/p=${var(timestamp)}/c=${time}")
