-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add support for numeric time zone offsets in timestamp processor #13902
Add support for numeric time zone offsets in timestamp processor #13902
Conversation
The ingest node `date` processor support numeric time zone offsets, and the `add_locale` Beat processor adds the numeric timezone in numeric formats. Add support for these formats to the timestamp processor for consistency with the other processors.
4f98148
to
2b96497
Compare
@@ -84,6 +84,20 @@ func newFromConfig(c config) (*processor, error) { | |||
return p, nil | |||
} | |||
|
|||
func loadLocation(timezone string) (*time.Location, error) { | |||
timezoneFormats := []string{"-07", "-0700", "-07:00"} |
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.
Should timezoneFormats here be a global variable? (No need to change it if you prefer this.)
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.
Will we support Z0700 Z07:00
as well? I was reading https://yourbasic.org/golang/format-parse-string-time-date-example/ to see what are the offset/timezone format there are.
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.
I saw this format in the Go documentation, I think this is only useful in complete timestamps to format times with numeric zero timezones (UTC) as Z
, or to parse Z
as zero timestamps.
In our case here we are not parsing complete timestamps, but only timezones, that come from configuration. We could use these formats to support Z
as a valid value for the timezone setting (as timezone: 'Z'
), but I am not sure if we want to do that, specially when there are more usual alternatives that will work, as timezone: 'Etc/UTC'
, or timezone: '+0000'
.
@kaiyan-sheng |
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.
Thanks, looks good to me.
jenkins, test this again please |
The ingest node
date
processor supports numeric time zone offsets,and the
add_locale
Beat processor adds the numeric timezone in numericformats. Add support for these formats to the timestamp processor for
consistency with the other processors.
This is needed in #13893, where a javascript pipeline needs the timezone
set by the
add_locale
processor to generate the timestamp using thetimestamp
processor.