Skip to content

Commit

Permalink
fix TryReadSqlDateTime
Browse files Browse the repository at this point in the history
  • Loading branch information
Wraith2 committed Feb 23, 2022
1 parent 50a4519 commit 5cfd6dd
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6856,27 +6856,27 @@ private bool TryReadSqlDateTime(SqlBuffer value, byte tdsType, int length, byte
{
return false;
}

ReadOnlySpan<byte> dateTimeData = datetimeBuffer.Slice(0, length);
switch (tdsType)
{
case TdsEnums.SQLDATE:
Debug.Assert(length == 3, "invalid length for date type!");
value.SetToDate(datetimeBuffer);
value.SetToDate(dateTimeData);
break;

case TdsEnums.SQLTIME:
Debug.Assert(3 <= length && length <= 5, "invalid length for time type!");
value.SetToTime(datetimeBuffer, scale, scale);
value.SetToTime(dateTimeData, scale, scale);
break;

case TdsEnums.SQLDATETIME2:
Debug.Assert(6 <= length && length <= 8, "invalid length for datetime2 type!");
value.SetToDateTime2(datetimeBuffer, scale, scale);
value.SetToDateTime2(dateTimeData, scale, scale);
break;

case TdsEnums.SQLDATETIMEOFFSET:
Debug.Assert(8 <= length && length <= 10, "invalid length for datetimeoffset type!");
value.SetToDateTimeOffset(datetimeBuffer, scale, scale);
value.SetToDateTimeOffset(dateTimeData, scale, scale);
break;

default:
Expand Down

0 comments on commit 5cfd6dd

Please sign in to comment.