What's the approach for queries then? For example, if I save an
entity with a DateTime property which gets converted to UTC I assume
any date related query arguments would also need to be converted to
UTC before being passed in? Just one more issue a client code
developer will need to consider. This is a much stickier problem than
I originally thought and I'm starting to come around to storing and
returning UTC across the board...still a pain in the arse though.
Thanks,
JC
On May 11, 10:32 am, James Avery <
jav...@infozerk.com> wrote:
> I agree with that, I think we save as UTC and return as UTC is the best bet.
> I think doing this is a best practice anyway, so forcing people into a best
> practice isn't a bad thing.
>
> -James
>
>
>
>
>
> On Tue, May 11, 2010 at 11:31 AM, Andrew Theken <
athe...@gmail.com> wrote:
> > We implicitly convert it to UTC when sending it to Mongo. This will not
> > change (unless Mongo/BSON adds support for datetime with timezone, which I
> > don't expect to happen in the short term, as the current mechanism is
> > adequate for most purposes).
>
> > The only real issue is on the inbound from Mongodb. We could (and currently
> > do) return as UTC, understanding that the value received by the client may
> > be (conceptually) "different" than the one they stored. Or, do a
> > .ToLocalTime(), which *still* might be a value (conceptually)"different"
> > than the one they sent to MongoDB.
>
> > Normally I wouldn't like to expose clients to the internals of the
> > persistence layer.. However, in this case I lean towards automatically
> > converting to UTC on serialization, and returning UTC on deserialization.
>
> > //Andrew Theken
>
> > On Tue, May 11, 2010 at 11:14 AM, Björn Graf <
bjoern.g...@gmail.com>wrote:
>
> >> On Tue, May 11, 2010 at 1:15 PM, Andrew Theken <
athe...@gmail.com> wrote:
> >> > I am not really sure what to to, even UTC can produce issues. It's
> >> > actually a pretty simple change, I'm open to doing it either way,
> >> > depending on the prevailing wisdom of the group.
>
> >> What about leaving the conversion issue to the user and just store the
> >> time as if it were given in UTC by just stripping any timezone
> >> information (e.g. 2010-05-11 17:05:00+02:00 would be stored as
> >> 2010-05-11 17:05:00) when moving the value to BSON? Doing the
> >> conversion implicitly will cause issues for some users sooner or
> >> later: doing the DateTime. ToUniversalTime()/ToLocalTime() dance when
> >> the user stores values for timezones different than the local one
> >> would result in “unexpected” (for the user) values.
>
> >> Another option could be to just do the ToUniversalTime during storing
> >> and leave it up to the user to deal with her timezone needs…
>
> >> The “We give up” (and not so serious) solution would be to just throw
> >> an exception when the DT ain’t in UTC ;)
>
> >> In the end I just hate date and time as much as anyone else :)
>
> >> -- bg
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "NoRM mongodb" group.
> >> To post to this group, send email to
norm-m...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >>
norm-mongodb...@googlegroups.com<norm-mongodb%2Bunsubscribe@google
groups.com>
> >> .
> >
norm-mongodb...@googlegroups.com<norm-mongodb%2Bunsubscribe@google
groups.com>
> > .
> Infozerk Inc. -
http://www.infozerk.com
> For more options, visit this group athttp://
groups.google.com/group/norm-mongodb?hl=en.