diff --git a/.gitignore b/.gitignore index c8a84ca4..0bb62b58 100644 --- a/.gitignore +++ b/.gitignore @@ -203,3 +203,5 @@ fabric.properties # Our own folders artifacts/ +.vs/YouTrackSharp/v15/sqlite3/storage.ide +.idea/.idea.YouTrackSharp/.idea/inspectionProfiles/profiles_settings.xml diff --git a/src/YouTrackSharp/Json/UnixDateTimeOffsetConverter.cs b/src/YouTrackSharp/Json/UnixDateTimeOffsetConverter.cs index d623dc04..2c0360d0 100644 --- a/src/YouTrackSharp/Json/UnixDateTimeOffsetConverter.cs +++ b/src/YouTrackSharp/Json/UnixDateTimeOffsetConverter.cs @@ -5,7 +5,7 @@ namespace YouTrackSharp.Json { /// - /// A JSON convertor that can convert a unix timestamp into a value and vice-versa. + /// A JSON convertor that can convert a unix timestamp (in milliseconds) into a value and vice-versa. /// public class UnixDateTimeOffsetConverter : DateTimeConverterBase @@ -15,11 +15,11 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s { if (value is DateTimeOffset) { - writer.WriteValue(((DateTimeOffset)value).ToUnixTimeSeconds()); + writer.WriteValue(((DateTimeOffset)value).ToUnixTimeMilliseconds()); } else if (value is DateTime) { - writer.WriteValue(new DateTimeOffset((DateTime)value).ToUnixTimeSeconds()); + writer.WriteValue(new DateTimeOffset((DateTime)value).ToUnixTimeMilliseconds()); } else { diff --git a/tests/YouTrackSharp.Tests/Json/UnixDateTimeOffsetConverterTests.cs b/tests/YouTrackSharp.Tests/Json/UnixDateTimeOffsetConverterTests.cs index e6d566e6..a784787f 100644 --- a/tests/YouTrackSharp.Tests/Json/UnixDateTimeOffsetConverterTests.cs +++ b/tests/YouTrackSharp.Tests/Json/UnixDateTimeOffsetConverterTests.cs @@ -34,8 +34,8 @@ public class WriteJson { public static IEnumerable GetData() { - yield return new object[] { new DateTimeOffset(2001, 01, 01, 10, 11, 0, TimeSpan.Zero), new DateTimeOffset(2001, 01, 01, 10, 11, 0, TimeSpan.Zero).ToUnixTimeSeconds() }; - yield return new object[] { new DateTimeOffset(2001, 01, 01, 10, 11, 0, TimeSpan.Zero).DateTime, new DateTimeOffset(new DateTimeOffset(2001, 01, 01, 10, 11, 0, TimeSpan.Zero).DateTime).ToUnixTimeSeconds() }; + yield return new object[] { new DateTimeOffset(2001, 01, 01, 10, 11, 0, TimeSpan.Zero), new DateTimeOffset(2001, 01, 01, 10, 11, 0, TimeSpan.Zero).ToUnixTimeMilliseconds() }; + yield return new object[] { new DateTimeOffset(2001, 01, 01, 10, 11, 0, TimeSpan.Zero).DateTime, new DateTimeOffset(new DateTimeOffset(2001, 01, 01, 10, 11, 0, TimeSpan.Zero).DateTime).ToUnixTimeMilliseconds() }; } [Theory]