thunder-client-support icon indicating copy to clipboard operation
thunder-client-support copied to clipboard

Extend {{#date}} system variable capabilities

Open haffi96 opened this issue 2 years ago • 4 comments

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 avatar Jul 08 '22 19:07 haffi96

@haffi96 thanks, will add to roadmap

I am thinking of this syntax.

{{#date, ‘X’, ‘+1day’}}

rangav avatar Jul 08 '22 19:07 rangav

I think the syntax should be :

{{#date, 'day', 1}}

Allowing

{{#date, 'second', -200}}

cgatian avatar Jul 15 '22 07:07 cgatian

@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'}}

rangav avatar Jul 15 '22 13:07 rangav

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.

cgatian avatar Jul 15 '22 16:07 cgatian

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.

Screenshot 2022-10-19 at 08 12 16

rangav avatar Oct 19 '22 08:10 rangav

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 avatar Oct 19 '22 08:10 haffi96

@haffi96 glad you like it.

I may open source some parts fo the extension in future.

rangav avatar Oct 19 '22 08:10 rangav