diff --git a/src/Cassandra/Serialization/Primitive/DateTimeOffsetSerializer.cs b/src/Cassandra/Serialization/Primitive/DateTimeOffsetSerializer.cs index de3b3aeb8..f5d63b1a3 100644 --- a/src/Cassandra/Serialization/Primitive/DateTimeOffsetSerializer.cs +++ b/src/Cassandra/Serialization/Primitive/DateTimeOffsetSerializer.cs @@ -28,6 +28,7 @@ public override ColumnTypeCode CqlType internal static DateTimeOffset Deserialize(byte[] buffer, int offset) { var milliseconds = BeConverter.ToInt64(buffer, offset); + if (milliseconds < MinValueOfDateTimeOffsetAsUnixTimeMilliseconds) milliseconds = MinValueOfDateTimeOffsetAsUnixTimeMilliseconds; return UnixStart.AddTicks(TimeSpan.TicksPerMillisecond * milliseconds); } diff --git a/src/Cassandra/Serialization/TypeSerializer.cs b/src/Cassandra/Serialization/TypeSerializer.cs index 8ddc7324f..8abf466db 100644 --- a/src/Cassandra/Serialization/TypeSerializer.cs +++ b/src/Cassandra/Serialization/TypeSerializer.cs @@ -50,6 +50,7 @@ public abstract class TypeSerializer public static readonly TypeSerializer PrimitiveTimeUuidSerializer = new TimeUuidSerializer(); internal static readonly DateTimeOffset UnixStart = new DateTimeOffset(1970, 1, 1, 0, 0, 0, 0, TimeSpan.Zero); + internal static readonly long MinValueOfDateTimeOffsetAsUnixTimeMilliseconds = -62135596800000; internal static byte[] GuidShuffle(byte[] b, int offset = 0) {