Skip to content

Commit 7863506

Browse files
committed
Clarify the DateTimeKind being used in QueryDate test.
1 parent 2ae3316 commit 7863506

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tests/SideBySide/DataTypes.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ public async Task GetGuid(string column, Type fieldType)
501501
[InlineData("`Timestamp`", "TIMESTAMP", new object[] { null, "1970 01 01 0 0 1", "2038 1 18 3 14 7 999999", null, "2016 4 5 14 3 4 567890" })]
502502
public void QueryDate(string column, string dataTypeName, object[] expected)
503503
{
504-
DoQuery("times", column, dataTypeName, ConvertToDateTime(expected), reader => reader.GetDateTime(column.Replace("`", "")));
504+
DoQuery("times", column, dataTypeName, ConvertToDateTime(expected, DateTimeKind.Unspecified), reader => reader.GetDateTime(column.Replace("`", "")));
505505
#if !BASELINE
506506
DoQuery("times", column, dataTypeName, ConvertToDateTimeOffset(expected), reader => reader.GetDateTimeOffset(0), matchesDefaultType: false);
507507
#endif
@@ -1053,30 +1053,30 @@ private void DoQuery<TException>(
10531053
}
10541054
}
10551055

1056-
private static object[] ConvertToDateTime(object[] input)
1056+
private static object[] ConvertToDateTime(object[] input, DateTimeKind kind)
10571057
{
10581058
var output = new object[input.Length];
10591059
for (int i = 0; i < input.Length; i++)
10601060
{
10611061
var value = SplitAndParse(input[i]);
10621062
if (value?.Length == 3)
1063-
output[i] = new DateTime(value[0], value[1], value[2]);
1063+
output[i] = new DateTime(value[0], value[1], value[2], 0, 0, 0, kind);
10641064
else if (value?.Length == 6)
1065-
output[i] = new DateTime(value[0], value[1], value[2], value[3], value[4], value[5]);
1065+
output[i] = new DateTime(value[0], value[1], value[2], value[3], value[4], value[5], kind);
10661066
else if (value?.Length == 7)
1067-
output[i] = new DateTime(value[0], value[1], value[2], value[3], value[4], value[5], value[6] / 1000).AddTicks(value[6] % 1000 * 10);
1067+
output[i] = new DateTime(value[0], value[1], value[2], value[3], value[4], value[5], value[6] / 1000, kind).AddTicks(value[6] % 1000 * 10);
10681068
}
10691069
return output;
10701070
}
10711071

10721072
private static object[] ConvertToDateTimeOffset(object[] input)
10731073
{
10741074
var output = new object[input.Length];
1075-
var dateTimes = ConvertToDateTime(input);
1075+
var dateTimes = ConvertToDateTime(input, DateTimeKind.Utc);
10761076
for (int i = 0; i < dateTimes.Length; i++)
10771077
{
10781078
if (dateTimes[i] != null)
1079-
output[i] = new DateTimeOffset(DateTime.SpecifyKind((DateTime)dateTimes[i], DateTimeKind.Utc));
1079+
output[i] = new DateTimeOffset((DateTime) dateTimes[i]);
10801080
}
10811081
return output;
10821082
}

0 commit comments

Comments
 (0)