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

DateTimeOffset loses time zone offset #360

Open
TristanMoss opened this issue Apr 5, 2015 · 5 comments
Open

DateTimeOffset loses time zone offset #360

TristanMoss opened this issue Apr 5, 2015 · 5 comments

Comments

@TristanMoss
Copy link

DateTimeOffset is stored as UTC ticks. The consequence is that the data read back lacks the time zone offset; however, it still accurately represents the correct moment in time.

Store this: "2014-06-11T20: 24: 01.8325787-07: 00"
You read back: "2014-06-12T03: 24: 01.8325787+00: 00"

They represent the same moment in time, but the first contained a timezone offset.

A work around is to store a DateTimeOffset's 'Offset' and 'Ticks' separately and rebuild an accurate DateTimeOffset on read. This does mean range queries are more difficult.

@nbelley
Copy link

nbelley commented Sep 25, 2015

Anything on this?

@amirmujkic
Copy link

Any other workaround or library that supports this?

@nbelley
Copy link

nbelley commented Oct 23, 2015

Work around is to save both parts separatly in the database and build them back on load.

@praeclarum
Copy link
Owner

Yeah I just noticed this myself, sorry for the trouble.

My thoughts are to store the offset in an auxiliary column and keep the UTC date time in the main column. This should allow compares to keep working and will only fail if people write their own queries.

@Hackmodford
Copy link

Just had this bite me.

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

No branches or pull requests

5 participants