TestPlan Working with DateTime
Document

Working with DateTime

by Group Public on Monday June 22 2009 @ 10:06:50 (1/1 Points)

Tutorial ↪User Guide ✑ Reply ✓ Stick It ✗ Ditch It ⚐ Tag It

TestPlan has a few basic functions to manipulate DateTime variables. These will allow you to select time ranges for a fixed period, or relative to the current time.

DateTime variables in TestPlan include both a date and a time. There are, at this moment, not independent date and time types -- you can however use formatDate if you need to represent just one component.

Now

The current DateTime is available in the context as Var:DateTime. You can try this with this code:

set %Now% %Var:DateTime%
Notice %Now%

Formatting

Refer to formatDate for a more complete reference.

To quickly show just the date or time part of a DateTime use the example below.

set %Now% %Var:DateTime%

set %Date% as formatDate with
  %Date% %Now%
  %Major% DATE
  %Format% MEDIUM
end
Notice %Date%

set %Time% as formatDate with
  %Date% %Now%
  %Major% TIME
  %Format% FULL
end
Notice %Time%

Duration

To add a certain duration offset to a DateTime you can use the dateTimeBinOp function.

This example will subtract 24 hours from the DateTime.

set %Time24H% as dateTimeBinOp %Var:DateTime% + -PT24H
Notice %Time24H%

Comparing Durations

Durations can also be compared with each other. This can be used to determine if a certain period of time has elapsed since some event.

set %Duration% as dateTimeBinOp %DateA% - %DateB%
if durationComp %Duration% > PT10H
  # more than ten hours has passed between the events.
end

Refer to durationComp for more details.

© 2008-2010 edA-qa mort-ora-y
Using Persephone and TestPlan
Tag: