Hi,

> Am 31.03.2017 um 17:16 schrieb Hilaire <hila...@drgeo.eu>:
> 
> Hi,
> 
> As far as I see when I store a DateAndTime with local time,
> "2017-03-31T17:10:46.137086+02:00", then I fetch it back, I got an UTC
> DateAndTime  "2017-03-31T15:10:46.137086+00:00".
> 
> Am I doing something wrong or do I need to use a mongo description to
> correct that. But wait, even so, I will not know what was the initial
> local time.
> 
> How do you usually deal such issue?
> 
it's a pitty. BSON only supports a date type which is date and time in UTC. So 
the offset information is stripped off and that is the reason why you get it 
this way. I fell over this a lot. Especially when you use a local midnight 
DateAndTime store it in mongo, read it and then do #asDate you will end up 
having one day before. Very annoying.
I think we shouldn't store DateAndTime as BSON date. We should create a custom 
type that includes timezone offset information.

Norbert


Reply via email to