Skip to content

Conversation

rebelzach
Copy link

DateTime types that are stored as strings should mimick the behavior of dates stored as ticks.

Currently when requesting a date from a db connection where dates are stored as strings it returns the date in local time, which is unexpected, and not congruent with the behavior when storing DateTime as ticks

@@ -473,7 +473,7 @@ private object ReadCol(IDbStatement stmt, int index, ColType type, Type clrType)
{
return new DateTime(_sqlitePlatform.SQLiteApi.ColumnInt64(stmt, index), DateTimeKind.Utc);
}
return DateTime.Parse(_sqlitePlatform.SQLiteApi.ColumnText16(stmt, index), CultureInfo.InvariantCulture);
return DateTime.Parse(_sqlitePlatform.SQLiteApi.ColumnText16(stmt, index), CultureInfo.InvariantCulture).ToUniversalTime();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to use return DateTime.Parse(_sqlitePlatform.SQLiteApi.ColumnText16(stmt, index), CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal)

@@ -488,7 +488,7 @@ private object ReadCol(IDbStatement stmt, int index, ColType type, Type clrType)
}
else
{
value = DateTime.Parse(_sqlitePlatform.SQLiteApi.ColumnText16(stmt, index), CultureInfo.InvariantCulture);
value = DateTime.Parse(_sqlitePlatform.SQLiteApi.ColumnText16(stmt, index), CultureInfo.InvariantCulture).ToUniversalTime();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to use return DateTime.Parse(_sqlitePlatform.SQLiteApi.ColumnText16(stmt, index), CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants