-
Notifications
You must be signed in to change notification settings - Fork 1.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
vrl format_timestamp timezone always +0 #20605
Comments
Hi @coredump17 ! Thanks for filing this. I'm having a hard time reproducing though. My local timezone is PDT:
And, in the VRL console, it correctly parses with the offset:
Here you can see it added 8 hours (rather than 7) because it was "standard time" (-0800) at the date encoded in that timestamp.
This also works per the first example you see in vectordotdev/vrl#853. Can you provide the output of |
Hi @jszwedko $ date +'%z' $ date $ .t = get_timezone_name!() initially i thought it might not be seeing the system timezone but get_timezone_name!() shows the correct timezone name (above). Wondering if the UK's BST (+1) and GMT (+0) time change could be the cause ( https://www.gov.uk/when-do-the-clocks-change ) i have just managed to replicate this using your alpine dockerhub container.
terminal:
vrl:
|
@coredump17 I think the issue is that the timezone for the date you have, March 6th 2024, will not be BDT, but instead BWT (British Winter Time) (+0000). |
@jszwedko - legend! You are very correct "%d/%m/%Y %T should be "%m/%d/%Y %T for this application log! Sorry to waste your time but thanks for helping me with this! |
No problem! Happy we got it resolved. |
A note for the community
Problem
parse_timestamp should use local timezone, global timezone variable or a passed in timezone as format_timestamp does. Instead, incorrectly defaults to UTC.
Configuration
A workaround can be to get the timezone from now() and append to the original timestamp but it would be much more cleaner to have parse_timestamp handle timezones (default to system if timezone is not passed).
$ .timestamp = "06/03/2024 20:27:00"
"06/03/2024 20:27:00"
$ .tz = format_timestamp!(value: now() , timezone: "Europe/London", format: "%z")
"+0100"
$ .t_and_tz = to_string(.timestamp) + ":" + .tz
"06/03/2024 20:27:00:+0100"
$ .timestamp2 = parse_timestamp!(.t_and_tz, format: "%d/%m/%Y %T:%z")
t'2024-03-06T19:27:00Z'
Version
vector 0.38.0
Debug Output
Example Data
No response
Additional Context
No response
References
No response
The text was updated successfully, but these errors were encountered: