Skip to content

Commit 61a40a0

Browse files
Updated ShdrLine to fix issue #98 with parsing timestamp.
Seems to be an issue with System.DateTime.TryParseExact() method that expects 7 fractional seconds. Parse fails when trying to parse with only 6 or fewer. This is discussed as an issue in the StackOverflow question below: https://stackoverflow.com/questions/3556144/how-to-create-a-net-datetime-from-iso-8601-format
1 parent c1aa396 commit 61a40a0

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

libraries/MTConnect.NET-SHDR/Shdr/ShdrLine.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2023 TrakHound Inc., All Rights Reserved.
1+
// Copyright (c) 2025 TrakHound Inc., All Rights Reserved.
22
// TrakHound Inc. licenses this file to you under the MIT license.
33

44
using System;
@@ -71,7 +71,7 @@ internal static bool IsTimestamp(string s)
7171
// 16 is the minimum number of chars in a ISO 8601 Timestamp (ex. 1900-01-01T00:00)
7272
if (x.Length > 16 && x[4] == '-' && x[7] == '-')
7373
{
74-
if (DateTime.TryParseExact(x, "o", _enUS, DateTimeStyles.AdjustToUniversal, out var y))
74+
if (DateTime.TryParse(x, null, DateTimeStyles.AdjustToUniversal, out var y))
7575
{
7676
return y;
7777
}

0 commit comments

Comments
 (0)