diff --git a/SlackNet.Tests/UtilsTests.cs b/SlackNet.Tests/UtilsTests.cs
index 87fe0d1..076893e 100644
--- a/SlackNet.Tests/UtilsTests.cs
+++ b/SlackNet.Tests/UtilsTests.cs
@@ -34,6 +34,7 @@ public void ToDateTime_FromTimestampString_InvalidTimestamp_ReturnsNull()
public void ToDateTime_FromTimestampString_ValidTimestamp_ReturnsDateTime()
{
"42".ToDateTime().ShouldBe(new DateTime(1970, 1, 1, 0, 0, 42));
+ "42.123456".ToDateTime().ShouldBe(new DateTime(1970, 1, 1, 0, 0, 42, 123, 456));
"-42".ToDateTime().ShouldBe(new DateTime(1969, 12, 31, 23, 59, 18));
}
@@ -60,6 +61,7 @@ public void ToDateTime_FromDecimal_Zero_ReturnsNull()
public void ToDateTime_FromDecimal_NonZero_ReturnsDateTime()
{
42m.ToDateTime().ShouldBe(new DateTime(1970, 1, 1, 0, 0, 42));
+ 42.123456m.ToDateTime().ShouldBe(new DateTime(1970, 1, 1, 0, 0, 42, 123, 456));
(-42m).ToDateTime().ShouldBe(new DateTime(1969, 12, 31, 23, 59, 18));
}
diff --git a/SlackNet/Utils.cs b/SlackNet/Utils.cs
index 9226de2..10a3c7f 100644
--- a/SlackNet/Utils.cs
+++ b/SlackNet/Utils.cs
@@ -34,7 +34,9 @@ public static class Utils
/// If timestamp is 0, returns null, otherwise a DateTime.
public static DateTime? ToDateTime(this decimal timestamp) =>
timestamp != 0
- ? DateTimeOffset.FromUnixTimeMilliseconds((long)(timestamp * 1000)).UtcDateTime
+ ? DateTimeOffset.FromUnixTimeMilliseconds((long)(timestamp * 1000))
+ .AddTicks((long)(timestamp * 1_000_000 % 1000 * 10)) // 10 ticks per microsecond
+ .UtcDateTime
: null;
///