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

Wrong (invalid) Syslog Timestamps (depends on location) #36

Open
ndsvw opened this issue Mar 19, 2020 · 0 comments
Open

Wrong (invalid) Syslog Timestamps (depends on location) #36

ndsvw opened this issue Mar 19, 2020 · 0 comments

Comments

@ndsvw
Copy link

ndsvw commented Mar 19, 2020

The month of a Syslog timestamp is defined as one of these values: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec (https://tools.ietf.org/html/rfc3164#section-4.1.2)

But if you are located in special countries (Germany for example, but a lot more), the line
timestamp = String.Concat(dt.ToString("MMM "), day, dt.ToString(" HH:mm:ss"));
could result in month names like "Mrz", "Dez"...

They are not valid!

This is easily solvable by adding CultureInfo.InvariantCulture as 2nd parameter of DateTime.toString:

timestamp = String.Concat(dt.ToString("MMM ", CultureInfo.InvariantCulture), day, dt.ToString(" HH:mm:ss", CultureInfo.InvariantCulture));

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

No branches or pull requests

1 participant