Date
formatting...Module contains step implementations for the Date task.
Parse
Create an instance of the Date task.
Parses a datetime string and transforms it according to specified arguments.
See Date task documentation for more information about arguments.
This step is useful when changes has to be made to a datetime representation during an iteration of a scenario.
Example
...
And value for variable "date1" is "none"
And value for variable "date2" is "none"
And value for variable "date3" is "none"
And value for variable "AtomicDate.test" is "now"
Then parse date "2022-01-17 12:21:37 | timezone=UTC, format="%Y-%m-%dT%H:%M:%S.%f", offset=1D" and save in variable "date1"
Then parse date "{{ AtomicDate.test }} | offset=-1D" and save in variable "date2"
Then parse date "{{ datetime.now() }} | offset=1Y" and save in variable "date3"
Arguments
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
datetime string and arguments |
required |
variable
|
str
|
name of, initialized, variable where response will be saved in |
required |
Format
value
Name | Type | Description | Default |
---|---|---|---|
date |
str | datetime |
string representation of a date and/or time or a datetime object, e.g. datetime.now() |
required |
format |
str |
python strftime format string or ISO-8601:[DateTime|Time][:ms][:no-sep] |
required |
timezone |
str |
valid timezone name | None (local) |
offset |
str |
time span string describing the offset, Y = years, M = months, D = days, h = hours, m = minutes, s = seconds, e.g. 1Y-2M10D |
None |
See wikipedia ISO 8601 for information about the ISO-8601
format. Specifying DateTime
would result in "Date and time with the offset"
and Time
results in everything after "T" in the same example.
In addition to this it is also possible to append milliseconds with :ms
and remove all the seperators in the date and time with :no-sep
.