Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTime.MinValue should not be converted to utc #297

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ErikWitkowski
Copy link

No description provided.

@oysteinkrog
Copy link
Owner

I'm weary of adding special cases like this, can you explain the rationale behind it?

@ErikWitkowski
Copy link
Author

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: [email protected]
To: [email protected]
CC: [email protected]; [email protected]
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

@oysteinkrog
Copy link
Owner

What about DateTime.MaxValue?

@ErikWitkowski
Copy link
Author

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.

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.

2 participants