Previous Topic: Magic String Case SensitivityNext Topic: Understanding VSE Transactions


Magic Dates

A powerful date parser scans requests and responses are also scanned during recording. Anything matching a wide definition of date formats is recognized and translated to a magic date. In the example that is shown in Magic Strings, the magic date is:

{{ =doDateDeltaFromCurrent("yyyy-MM-dd","0D");/2008-12-17}}

The use of {{ }} notation is important here.

At run time, this string is translated as "generate a date of the format yyyy-MM-dd that is 0 days from the current date". That is, generate the current date.

If the original recording was taken on 1 February 2009 and the response contained the date 2009-02-10, the magic date string would be:

=doDateDeltaFromCurrent("yyyy-MM-dd","10D");/2009-02-10/

The 10D in the magic string means that the VSE generates a date in the response that is 10 days ahead of the current time. Therefore, if the VSE is in playback mode on 12 June 2010, the response contains the string 2010-06-22.

The valid parameters for date deltas are:

Another variant of magic dates is:

doDateDeltaFromRequest

Use the doDateDeltaFromRequest variant when a date is used as a parameter in the request and a date is seen in the response. For example, an airline reservation system could accept a seating request for a specific flight on a specific day. If that date is seen in the response, the VSE correctly substitutes the date in any subsequent responses.

A more sophisticated example is if the flight request generated a response that detailed a flight crossing the International Date Line. A flight from Los Angeles to Sydney arrives two days later than the departure according to the calendar date even though the flight time is 14 hours. In this example, the response contains something like:

doDateDeltaFromRequest("yy-MM-dd", "2D")

If VSE processed a similar request for a flight departing LAX on 19-June-2013, it includes the correct arrival date of 21-June-2013 in the response.

Note: You can add any valid date and time formats, including the ones that have zones, to lisa.properties for magic date calculations.