Skip to content

Conversation

@edmocosta
Copy link
Contributor

Description:

Added support for locale in the Time converter, so it can parse timestamps written in non-english languages.

The new locale parameter's value is optional, and can be specified as:
Time("Febrero 25 lunes, 2002, 02:03:04 p.m.", "%B %d %A, %Y, %r", "America/New_York", "es-ES")

The value must be a well-formed BCP-47 language tag, and a known CLDR v45 locale.

Link to tracking Issue: #32978

Testing: Unit tests

Documentation: ottl/README was updated to include the new optional locale parameter.

- `Time("2012-11-01T22:08:41+0000 EST", "%Y-%m-%dT%H:%M:%S%z %Z")`
- `Time("2023-05-26 12:34:56", "%Y-%m-%d %H:%M:%S", "America/New_York")`

`locale` specifies the input language of the `target` value. It is used to interpret timestamp values written in a specific language,
Copy link
Member

Choose a reason for hiding this comment

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

Please add something that conveys that when not set english is the local that gets used.

Copy link
Member

@TylerHelmuth TylerHelmuth left a comment

Choose a reason for hiding this comment

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

Please rebase

…lector-contrib into ottl_time_func_locale_support

# Conflicts:
#	pkg/ottl/ottlfuncs/func_time.go
@edmocosta edmocosta requested a review from a team as a code owner September 20, 2024 12:30
@edmocosta
Copy link
Contributor Author

Please rebase

Hi @TylerHelmuth, I've rebased and adapted it to the latest changes to avoid parsing the c-time layout in every operation (#35129). Thanks!

@TylerHelmuth TylerHelmuth merged commit d98a4f6 into open-telemetry:main Sep 20, 2024
@github-actions github-actions bot added this to the next release milestone Sep 20, 2024
jriguera pushed a commit to springernature/opentelemetry-collector-contrib that referenced this pull request Oct 4, 2024
…ry#35107)

**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->

Added support for locale in the `Time` converter, so it can parse
timestamps written in non-english languages.

The new `locale` parameter's value is optional, and can be specified as:
`Time("Febrero 25 lunes, 2002, 02:03:04 p.m.", "%B %d %A, %Y, %r",
"America/New_York", "es-ES")`

The value must be a well-formed BCP-47 language tag, and a known
[CLDR](https://cldr.unicode.org) v45 locale.

**Link to tracking Issue:**
open-telemetry#32978

**Testing:** Unit tests

**Documentation:** ottl/README was updated to include the new optional
`locale` parameter.
@edmocosta edmocosta deleted the ottl_time_func_locale_support branch October 7, 2024 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants