diff --git a/src/Tomlyn.Tests/BasicTests.cs b/src/Tomlyn.Tests/BasicTests.cs index d8c742d..06f86db 100644 --- a/src/Tomlyn.Tests/BasicTests.cs +++ b/src/Tomlyn.Tests/BasicTests.cs @@ -38,6 +38,21 @@ public void TestHelloWorld() Assert.AreEqual(new TomlArray() { 4, 5, 6 }, list); } + [Test] + [TestCase(7, 32, 0, 0)] + [TestCase(7, 32, 0, 999)] + [TestCase(0, 32, 0, 0)] + public void TestLocalTime(int hour, int minute, int second, int millisecond) + { + var toml = $@"time = {hour:D2}:{minute:D2}:{second:D2}.{millisecond:D3}"; + var localTime = (TomlDateTime)Toml.ToModel(toml)["time"]; + + Assert.AreEqual(hour, localTime.DateTime.Hour); + Assert.AreEqual(minute, localTime.DateTime.Minute); + Assert.AreEqual(second, localTime.DateTime.Second); + Assert.AreEqual(millisecond, localTime.DateTime.Millisecond); + } + [Test] public void TestHelloWorldWithCustomModel() { diff --git a/src/Tomlyn/Parsing/Lexer.cs b/src/Tomlyn/Parsing/Lexer.cs index c10a4d3..5497851 100644 --- a/src/Tomlyn/Parsing/Lexer.cs +++ b/src/Tomlyn/Parsing/Lexer.cs @@ -525,7 +525,7 @@ private void ReadNumberOrDate(char32? signPrefix = null, TextPosition? signPrefi previousCharIsDigit = _c == '0'; if (previousCharIsDigit) { - _textBuilder.Append(_c); + _textBuilder.Append((char)_c); zeroDigit++; } end = _position;