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

Use invariant culture for CBOR #92539

Merged
merged 2 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public DateTimeOffset ReadDateTimeOffset()
string dateString = ReadTextString();

// TODO determine if conformance modes should allow inexact date sting parsing
if (!DateTimeOffset.TryParseExact(dateString, CborWriter.Rfc3339FormatString, null, DateTimeStyles.RoundtripKind, out DateTimeOffset result))
if (!DateTimeOffset.TryParseExact(dateString, CborWriter.Rfc3339FormatString, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out DateTimeOffset result))
{
throw new CborContentException(SR.Cbor_Reader_InvalidDateTimeEncoding);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
using System.Globalization;
using System.Numerics;

namespace System.Formats.Cbor
Expand Down Expand Up @@ -42,8 +43,8 @@ public void WriteDateTimeOffset(DateTimeOffset value)
#else
value.Offset == TimeSpan.Zero ?
#endif // NET8_0_OR_GREATER
value.UtcDateTime.ToString(Rfc3339FormatString) : // prefer 'Z' over '+00:00'
value.ToString(Rfc3339FormatString);
value.UtcDateTime.ToString(Rfc3339FormatString, CultureInfo.InvariantCulture) : // prefer 'Z' over '+00:00'
value.ToString(Rfc3339FormatString, CultureInfo.InvariantCulture);

WriteTag(CborTag.DateTimeString);
WriteTextString(dateString);
Expand Down