Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: show conversion from duration to seconds #44

Merged
merged 1 commit into from
Jul 17, 2024

Conversation

cbandy
Copy link

@cbandy cbandy commented Jul 6, 2024

Description

I use Go templates to produce machine-readable files, and one of the challenges I face is producing amounts of time as seconds and milliseconds. I want to write values like "5 minutes" or "30 seconds" for the benefit of file maintainers and have a computer do the math to turn them into numbers.

The toDuration function satisfies my use case and seems valuable to show in the documentation.

Changes

One more example for the toDuration function.

Fixes

Checklist

  • I have read the CONTRIBUTING.md document.
  • My code follows the code style of this project.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation accordingly.
  • This change requires a change to the documentation on the website.

Additional Information

This example matches this test:

{"TestCallingOnIt", `{{ (toDuration "1h30m").Seconds }}`, "5400", nil},

@42atomys 42atomys added aspect/documentation 📚 Improvements or additions to documentation state/done ✔ This is done! labels Jul 17, 2024
Copy link
Member

@42atomys 42atomys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cbandy, thanks for your contribution 🎉 💜

Sorry for the delay, I'm in vacation since 2 weeks

@42atomys 42atomys merged commit 1192843 into go-sprout:main Jul 17, 2024
8 checks passed
@cbandy cbandy deleted the doc-duration branch July 18, 2024 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aspect/documentation 📚 Improvements or additions to documentation state/done ✔ This is done!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants