Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
Use DateTimeStyles.AdjustToUniversal.
Browse files Browse the repository at this point in the history
Using DateTimeStyles.AdjustToUniversal instead of DateTimeStyles.None returns a correct but converted-to-Local time (not Unspecified) if a Utc time was saved (which would have caused a Z to be appended). (Behavior if a Local or Unspecified time was saved is not changed by DateTimeStyles.AdjustToUniversal, i.e. it still returns Unspecified in both cases.)
  • Loading branch information
ejball committed May 3, 2018
1 parent 653e49b commit 4ecf936
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/System.Data.SQLite/SQLiteDataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ public override object GetValue(int ordinal)
case SQLiteColumnType.Text:
int stringLength = NativeMethods.sqlite3_column_bytes(m_currentStatement, ordinal);
string stringValue = SQLiteConnection.FromUtf8(NativeMethods.sqlite3_column_text(m_currentStatement, ordinal), stringLength);
return dbType == DbType.DateTime ? (object) DateTime.ParseExact(stringValue, s_dateTimeFormats, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None) :
return dbType == DbType.DateTime ? (object) DateTime.ParseExact(stringValue, s_dateTimeFormats, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AdjustToUniversal) :
(object) stringValue;

default:
Expand Down

0 comments on commit 4ecf936

Please sign in to comment.