thunder-client-support
thunder-client-support copied to clipboard
Extend {{#date}} system variable capabilities
Is your feature request related to a problem? Please describe.
Adding the ability to auto-generate a timestamp which is +/- of the current timestamp
Describe the solution you'd like
Existing functionality: {{#date,'X'}} lets us auto-generate the current timestamps for request
Can this be extended to allow for this: Something like {{#date+/-1day, 'X'}} or {{#date+/-1hour}}
Where {{#date+1-day, 'X'}} would give the timestamp of current datetime + 1 day
Python snippet of what I mean:
In [8]: now = datetime.now().replace(microsecond=0)
In [9]: now
Out[9]: datetime.datetime(2022, 7, 8, 20, 33, 49)
In [10]: now.timestamp()
Out[10]: 1657308829.0
In [11]: tmrw = now + timedelta(days=1)
In [12]: tmrw
Out[12]: datetime.datetime(2022, 7, 9, 20, 33, 49)
In [13]: tmrw.timestamp()
Out[13]: 1657395229.0
Implementation: Not sure but wouldn't mind contributing if system variables were open sourced
@haffi96 thanks, will add to roadmap
I am thinking of this syntax.
{{#date, ‘X’, ‘+1day’}}
I think the syntax should be :
{{#date, 'day', 1}}
Allowing
{{#date, 'second', -200}}
@cgatian 2nd argument we are using it for date format e.g {{#date, 'YYYY-MM-DD hh:mm:ss:fff'}}
.
So we have to use these date manipulation args after.
We could use like below
{{#date, 'YYYY-MM-DD hh:mm:ss:fff', 1, 'day'}}
Sorry for my laziness on that, I didn't look at the existing API and was browsing this issue in the middle of the night 😄 .
I was thinking of using an API similar to date-fns. So what you proposed would work great.
This feature is now implemented and published to marketplace, please update to v1.20.1
See all features released https://github.com/rangav/thunder-client-support/releases/tag/v1.20.1
Please let me know your feedback.

Amazing 👏🏽 , this will be really helpful going forward.
Side note: Are you planning on open sourcing the actual implementations of this project in the future? No worries if not. Asking because I'd love to contribute on this
@haffi96 glad you like it.
I may open source some parts fo the extension in future.