leikind / wice_grid

A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters
MIT License
537 stars 215 forks source link

Unexpected result when filter datetime field in specified time zone #185

Closed fibers closed 9 years ago

fibers commented 9 years ago

The time zone is set to GMT +1100 through

config.time_zone = 'Australia/Sydney'  

The date helper is set to calender by

Wice::Defaults::HELPER_STYLE = :calendar

When I filter a datetime field 'created_at' by input the start date to '2014-10-21' and end date to '2014-10-21', the expected query should be

where created_at >= '2014-10-20 13:00:00' and created_at < '2014-10-21 13:00:00'

but actually the generated sql is

where created_at >= '2014-10-21' and created_at < '2014-10-22'

After I look into the source code, I find the following code in line 112 in file 'lib/wice/columns/column_datetime.rb'

conditions << opts[:fr].to_date

If I remove the 'to_date', the query will be generated correctly. What's the purpose of this 'to_date' conversion

fibers commented 9 years ago

Any comments ?

fibers commented 9 years ago

Anyone who can help on this?

leikind commented 9 years ago

check version 3.4.12 out