From 25c44ae817e167178e12a7f1b80796d6738739a8 Mon Sep 17 00:00:00 2001 From: Christoph Hausner <15180557+chausner@users.noreply.github.com> Date: Mon, 11 Dec 2023 18:48:09 +0100 Subject: [PATCH] Add support for timestamp format "HH:mm:ss,fff" --- .../Parsers/TimestampParserTest.cs | 15 +++++++++++++++ src/Tailviewer.Core/Parsers/TimestampParser.cs | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/Tailviewer.Core.Tests/Parsers/TimestampParserTest.cs b/src/Tailviewer.Core.Tests/Parsers/TimestampParserTest.cs index 297aa6972..2dc42c430 100644 --- a/src/Tailviewer.Core.Tests/Parsers/TimestampParserTest.cs +++ b/src/Tailviewer.Core.Tests/Parsers/TimestampParserTest.cs @@ -236,6 +236,21 @@ public void TestTryParse13() timestamp.Should().Be(new DateTime(2019, 7, 8, 16, 18, 58, 381)); } + [Test] + public void TestTryParse14() + { + var parser = new TimestampParser(); + parser.TryParse("19:50:58,998", + out var dateTime) + .Should() + .BeTrue(); + + dateTime.Hour.Should().Be(19); + dateTime.Minute.Should().Be(50); + dateTime.Second.Should().Be(58); + dateTime.Millisecond.Should().Be(998); + } + [Test] public void TestTryParseLongGarbageLine() { diff --git a/src/Tailviewer.Core/Parsers/TimestampParser.cs b/src/Tailviewer.Core/Parsers/TimestampParser.cs index 9e1171b67..9000ca5d3 100644 --- a/src/Tailviewer.Core/Parsers/TimestampParser.cs +++ b/src/Tailviewer.Core/Parsers/TimestampParser.cs @@ -70,6 +70,8 @@ public TimestampParser() // One of the most bizare formats: Time of day is apparently not interesting enough, just as are fractions of a second. // We do, however, get the seconds (in nano seconds) since the start of the application... new TimeOfDaySecondsSinceStartParser(), + + new DateTimeParser("HH:mm:ss,fff"), new DateTimeParser("HH:mm:ss.fff"), new DateTimeParser("HH:mm:ss") )