Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 4f42318

Browse files
committed
Merge pull request #332 from catlion/master
JsonSerializer.SerializeToString throws OutOfRangeException
2 parents 55a6deb + 019e8b8 commit 4f42318

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ServiceStack.Text/DateTimeExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static long ToUnixTimeMs(this DateTime dateTime)
4646
var dtUtc = dateTime;
4747
if (dateTime.Kind != DateTimeKind.Utc)
4848
{
49-
dtUtc = dateTime.Kind == DateTimeKind.Unspecified
49+
dtUtc = dateTime.Kind == DateTimeKind.Unspecified && dateTime > DateTime.MinValue
5050
? DateTime.SpecifyKind(dateTime.Subtract(LocalTimeZone.GetUtcOffset(dateTime)), DateTimeKind.Utc)
5151
: dateTime.ToStableUniversalTime();
5252
}
@@ -184,4 +184,4 @@ public static DateTime EndOfLastMonth(this DateTime from)
184184
}
185185
}
186186

187-
}
187+
}

0 commit comments

Comments
 (0)