Handlebars.Net.Helpers icon indicating copy to clipboard operation
Handlebars.Net.Helpers copied to clipboard

Support Offset for DateTime.Now (or another helper)

Open georgearnall opened this issue 1 year ago • 1 comments

I'm looking to achieve functionality similar to this in https://docs.wiremock.io/response-templating/dates-and-times/

{{now}}
{{now offset='3 days'}}
{{now offset='-24 seconds'}}
{{now offset='1 years'}}
{{now offset='10 years' format='yyyy-MM-dd'}}

WireMock uses this library under the hood.

It would be really useful to be able to add or remove time from the current date. I'm not concerned too much with how the API works just so long as it's possible.

As a proposal, it could work something like this:

{{DateTime.NowOffset offsetInDays='5'}}

Thanks

georgearnall avatar Sep 18 '24 12:09 georgearnall

Maybe you can use Linq?

Like: {{Linq x 'it.AddYears(1)'}}

StefH avatar Sep 18 '24 14:09 StefH

Cool thanks

georgearnall avatar Oct 02 '24 10:10 georgearnall