oysteinkrog / SQLite.Net-PCL

Simple, powerful, cross-platform SQLite client and ORM - Updated version with PCL support
MIT License
353 stars 162 forks source link

DateTime conversion problem #338

Open Maschina opened 7 years ago

Maschina commented 7 years ago

As soon as I am retrieving a stored value from sqlite back to the app, the DateTime values are not automatically converted back to local time. For example: I am storing a value such as 2016-11-23T15-23-00. When reading back this value while the machine that runs the app is configured for CET (UTC+1), the result will be 2016-11-23T14-23-00, which is GMT (UTC+0).

Maschina commented 7 years ago

337 fixes this issue

alanspires commented 7 years ago

I think this is by design not a bug

thornley-touchstar commented 7 years ago

@alanspires Yes, I think you are correct, although the behaviour does not seem to be consistent when StoreDateTimeAsTicks is false.

From what I can ascertain, regardless, the ORM will convert the datetime object to UTC when stored in the database, however on retrieval (ReadCol) it will convert to UTC only if stored as ticks. If stored as a string, it will convert to local time via DateTime.Parse().

So, SqlCommand.cs the calls to DateTime.Parse(), should be using DateTimeStyles.AdjustToUniversal.

What do you think?