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

feat: date generator functions #3327

Merged
merged 7 commits into from Nov 3, 2023
Merged

Conversation

mathnogueira
Copy link
Member

@mathnogueira mathnogueira commented Nov 1, 2023

This PR adds support for two new generator functions: date() and dateTime().

Motivation

This was asked by a user in our discord channel

About the functions

// returns the date in the time.DateOnly format (YYYY-MM-DD)
// if format is provided, it will be formatted based on it.
date(format optional<string>)

// returns the date and time in the time.RFC3339 format (2006-01-02T15:04:05Z07:00)
// if format is provided, it will be formatted based on it.
dateTime(format optional<string>)

Examples

date() : 2023-11-01
date("MM-DD-YYYY") : 11-01-2023
date("DD/MM/YYYY") : 01/11/2023
dateTime() : 2023-11-01T12:38:12Z03:00
dateTime("hh:mm:ss") : 12:38:12

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

Loom video

Add your loom video here if your work can be visualized

@@ -171,6 +171,7 @@ require (
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
gitlab.com/metakeule/fmtdate v1.2.2 // indirect
Copy link
Member Author

Choose a reason for hiding this comment

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

This library uses the time.Format function to format dates but it allows us to use the W3C format instead of go's magic numbers:

DD/MM/YYYY instead of 02/01/2006

Copy link
Member

@jfermi jfermi left a comment

Choose a reason for hiding this comment

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

Some editing suggestions.

mathnogueira and others added 4 commits November 1, 2023 14:22
Co-authored-by: Julianne Fermi <julianne@kubeshop.io>
Co-authored-by: Julianne Fermi <julianne@kubeshop.io>
Co-authored-by: Julianne Fermi <julianne@kubeshop.io>
Co-authored-by: Julianne Fermi <julianne@kubeshop.io>
@mathnogueira mathnogueira changed the title Feat/date generator functions Feat: date generator functions Nov 1, 2023
@mathnogueira mathnogueira changed the title Feat: date generator functions feat: date generator functions Nov 1, 2023
@mathnogueira mathnogueira merged commit d2ec14f into main Nov 3, 2023
37 checks passed
@mathnogueira mathnogueira deleted the feat/date-generator-functions branch November 3, 2023 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants