Open ErikWitkowski opened 8 years ago
Sure! This special case needs atention because today in SQLLite.NET-PCL, when you save a DateTime.MinValue to database and load it back, it's not a DateTime.MinValue anymore if you are west of London. When you do DateTime.MinValue.ToUniversalTime() on west of london, the result is bigger than DateTime.MinValue and can be considered a "real" datetime value. DateTime.MinValue should always stick with zero Ticks when saved to database, as it is the default value, and not a "real" date.
Date: Wed, 11 May 2016 10:56:18 -0700 From: notifications@github.com To: SQLite.Net-PCL@noreply.github.com CC: wr_erik@hotmail.com; author@noreply.github.com Subject: Re: [oysteinkrog/SQLite.Net-PCL] DateTime.MinValue should not be converted to utc (#297)
I'm weary of adding special cases like this, can you explain the rationale behind it?
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub
What about DateTime.MaxValue?
I don't have the same concern about MaxValue since it's not the default value for DateTime.
To be more specific, I've found this problem when moving data from SQLLite to SQLServer (through WebService integration), since SQLServer won't support the "01/01/01 03:00:00" value (result of MinValue plus 3 hours of my local time).
At first I've worked this around by creating all DateTime.MinValue by specifing utc:
DateTime myDateTime = DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Utc);
If we commit this code, people won't need the code above to properly initiate a datetime value.
I'm weary of adding special cases like this, can you explain the rationale behind it?