scoped_search icon indicating copy to clipboard operation
scoped_search copied to clipboard

Date querying test failures due to timezones

Open brocktimus opened this issue 11 years ago • 2 comments

I was looking at a few things today and was getting test failures for seemingly random reasons. I figured out later that I think its probably due to TZ conversions.

I was testing stuff before 8AM and I'm living in +8. So I'm guessing was 2013-03-16 but the DB entries were 2013-03-15 (because they're saved as UTC).

https://github.com/wvanbergen/scoped_search/blob/master/spec/integration/ordinal_querying_spec.rb#L191

https://github.com/wvanbergen/scoped_search/blob/master/spec/integration/ordinal_querying_spec.rb#L195

Does this reasoning sound about right? I've got a few ideas to try, like calling .to_utc or something on the date as well (if that's a thing!?).

brocktimus avatar Mar 16 '13 02:03 brocktimus

You can call .utc on a DateTime or Timestamp. I am not sure if this is part o Ruby or ActiveSupport though, and if it is available in all versions.

The tricky part is:

  • Can we always assume times in the DB are in UTC?
  • Can we always assume the time the user specifies in the query is in the same timezone as the server's timezone?

wvanbergen avatar Mar 16 '13 21:03 wvanbergen

Having said that, we should make sure our testsuite doesn't run into these timezone issues.

wvanbergen avatar Mar 16 '13 21:03 wvanbergen