How can I calculate a duration from start and end time #1479
Unanswered
kontango-bot
asked this question in
Q&A
Replies: 2 comments
-
It seems that vars are evaluated when they are called, so i don't think this approach will work either way. |
Beta Was this translation helpful? Give feedback.
0 replies
-
This is what I ended up with: vars:
start_time: { sh: date +%s }
tasks:
test:
cmds:
- sleep 5
- task: end_timer
- echo "Done."
end_timer:
cmds:
- "echo Duration: {{ .duration | duration }}"
vars:
duration: { sh: "echo $(( $(date +%s) - {{ .start_time }} ))" } |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
here's my taskfile:
This is invalid syntax, and i've tried a few other things (e.g. without parens) that also seem to be invalid.
Part of the problem is that
.start_time
gets converted to a string, which is not suprising. I'm not sure how to convert it back into a date before passing it intonow.Sub
. Or, if there is a way to storenow
without converting it to a string, that would be ideal.Beta Was this translation helpful? Give feedback.
All reactions