I am trying to use Venom to automate some API test, and I can use {{.venom.datetime}}
to get the current date and time, like 2023-11-22T16:43:25-05:00
. But I would like to get something like 2023-11-21T00:00:00
and 2023-11-21T23:59:59
. How to do that?
while there is no direct way to get that from the venom
framework itself, but you can use exec
steps for that.
See below examples where the date value is also stored in a var for being reused in subsequent steps
- name: Get yesterday date start of day
type: exec
script: date -v -1d "+%Y-%m-%dT00:00:00Z"
assertions:
- result.code ShouldEqual 0
info:
"yesterday_start date is {{.result.systemout}}"
vars:
yesterday_start:
from: result.systemout
- name: Get yesterday date end of day
type: exec
script: date -v -1d "+%Y-%m-%dT23:59:59Z"
assertions:
- result.code ShouldEqual 0
info:
"yesterday_end date is {{.result.systemout}}"
vars:
yesterday_end:
from: result.systemout
above shell commands are for mac, similar can be found for linux using -d
param