TimeZone and dateEquals filter

Hello,

I’ve encountered very annoying problems when trying to filter DateTime column for entities in a specified day. The only way I came up with was using custom filter and dateEquals, but neither macro, nor the component respect user’s timezone. Scenario:

  1. DB + JAVA Server in UTC
  2. User is in GMT+1
  3. Filter field with java.sql.Date as paramClass
  4. Instead of filtering between 00:00 and 23:59 of users timezone, it filters the same range in server’s timezone - user gets results between 1:00 and 00:59 of the next day

We needed to fix it by overriding com.haulmont.cuba.gui.components.filter.Param and com.haulmont.cuba.core.sys.querymacro.DateEqualsMacroHandler. Cuba handles user’s TimeZone in other place well, this is a real shame!

1 Like

Hi Jan,

Could you share your code or make a pull request?

Hello Konstantin,

my colleague create a pull request, feel free to integrate it:

One test is not passing anymore. I think it is due to non initialized AppContext.

Thank you. Please see my comments in the PR discussion. There is also a related issue.

Fair enough. We sadly do not have time to go through other truncating macros and as this was irritating our customer we had to deal with it somehow. I hope the PR have helped you a bit.

Sure, it clearly defines the problem and a possible solution. But I have no idea at the moment how to save other use cases with date parameter from breaking.

Hello Konstantin, I am currently struggling with this very same issue, was there another way of solving this problem found?
Thanks

Hi Tomas,
Unfortunately I cannot add anything to this old discussion.

I click on the link to the similar issue you refer to in post #4 but YouTrack does not seem to find it, is there a back-up or some documentation on it?
Thanks again

The link to the issue is broken now, we’ll fix it soon. Thanks for pointing this out.
But looks like the issue was fixed for CUBA v.6.8.0.
What version are you using?

We are currently using CUBA v.7.2.15.

OK, then you should use the user_timezone parameter in date-time macros as described in the docs.

1 Like