-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[pkg/ottl] introduce FormatTime() converter function #37112
base: main
Are you sure you want to change the base?
Conversation
e4a3e0b
to
22d9292
Compare
22d9292
to
e7aa7d2
Compare
Signed-off-by: odubajDT <[email protected]>
Signed-off-by: odubajDT <[email protected]>
e7aa7d2
to
aee7584
Compare
@@ -465,6 +465,7 @@ Available Converters: | |||
- [String](#string) | |||
- [Substring](#substring) | |||
- [Time](#time) | |||
- [FormatTime](#formattime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try to keep this list in alphabetical order.
@@ -1961,6 +1962,61 @@ Examples: | |||
- `Time("mercoledì set 4 2024", "%A %h %e %Y", "", "it")` | |||
- `Time("Febrero 25 lunes, 2002, 02:03:04 p.m.", "%B %d %A, %Y, %r", "America/New_York", "es-ES")` | |||
|
|||
### FormatTime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this section to same summary's position
|
||
Examples: | ||
|
||
- `FormatTime(Time("02/04/2023", "%m/%d/%Y"), "%A %h %e %Y")` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please include more examples?
if err != nil { | ||
return nil, err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to validate if t
is nil
and return an error, otherwise the function would panic if that happens.
Co-authored-by: Edmo Vamerlatti Costa <[email protected]>
Description
Adds a new
FormatTime(time, format)
converter to convert any time to a human readable string with the specified formatLink to tracking issue
Fixes #36870