Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

datetime_select and select_datetime inconsistent for various options

#4432

I tested following case with edge 2-3-stable branch.

discard_hour => true
datetime_select #=> yyyy month day
select_datetime #=> yyyy month day minutes
result is inconsistent

discard_minute => true
datetime_select #=> yyyy month day hours
select_datetime #=> yyyy month day hours
result is consistent

discard_second => true
datetime_select #=> yyyy month day hours minutes
select_datetime #=> yyyy month day hours minutes
result is consistent

ignore_date => true
datetime_select #=> hours minutes
select_datetime #=> yyyy month day hours minutes
result is inconsistent

discard_month => true
datetime_select #=> yyyy hours minutes
select_datetime #=> yyyy day hours minutes
result is inconsistent

I have not listed a few more cases where the result is inconsistent.

For the methods datetime_select and select_datetime which are mirror image methods, the expected behavior should be as consistent as possible.

Please let me know if it is something that should be fixed. I can put in a patch if I get a go ahead.

I actually wanted to fix ticket #1004 datetime_select to accept :ampm option #1004 datetime_select to accept :ampm option . However if this inconsistency is removed then code would be more streamlined and it would easier to patch ticket #1004 datetime_select to accept :ampm option.

Reported by Neeraj · April 18th, 2010 @ 03:16 AM

State: resolved
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Santiago Pastorino
    Santiago Pastorino

    What about this on 3.0?, can you provide the same information for 3.0?

    April 22nd, 2010 @ 08:18 PM

  2. Neeraj Singh
    Neeraj Singh

    For all the below mentioned options, result between datetime_select and select_datetime is consistent in rails3. Nice work rails team.

    discard_hour => true
    discard_minute => true
    discard_second => true
    ignore_date => true
    discard_month => true

    April 22nd, 2010 @ 09:52 PM

  3. Neeraj Singh
    Neeraj Singh

    Now that it it is clear that this issue is only relevant to 2.3.x branch, if it is something that should be fixed then do let me know. I do see that priority is low. However I looked at code and could provide a patch for 2.3.x.

    April 22nd, 2010 @ 09:53 PM

  4. Santiago Pastorino
    Santiago Pastorino
    • Milestone set to 2.3.6
    • State changed from new to open
    • Assigned user changed from Geoff Buesing to Santiago Pastorino

    Ok Neeraj Singh, please provide a patch with tests ;)

    April 22nd, 2010 @ 10:55 PM

  5. Neeraj Singh
    Neeraj Singh

    Hi Santiago,

    My previous report on everything working fine in rails3 was wrong. Sorry I was in the wrong rvm path.

    Here are the cases where result is inconsistent. I have verified that this case exists in both 2.3.5 and in rails3 edge.

    discard_hour => true
    datetime_select #=> yyyy month day
    select_datetime #=> yyyy month day minutes

    ignore_date => true
    datetime_select #=> hours minutes
    select_datetime #=> yyyy month day hours minutes

    discard_month => true
    datetime_select #=> yyyy hours minutes
    select_datetime #=> yyyy day hours minutes

    Working on it. First I will have a patch for 2.3.x and later for rails3. Sorry about the mistake in the previous report regarding rails3.

    April 23rd, 2010 @ 09:13 PM

  6. Santiago Pastorino
    Santiago Pastorino
    • Milestone cleared.
    • Tag changed from 2.3.6 to 2.3.6, 3.0, date_select

    Can you provide test cases and/or patches for this cases?.

    April 23rd, 2010 @ 09:30 PM

  7. Neeraj Singh
    Neeraj Singh
    • Tag changed from 2.3.6, 3.0, date_select to 2.3.6, 3.0, date_select, patch

    Attached is a patch against rails edge which brings more consistency between date helper methods.

    without patch
    =============
    no options
    f.datetime_select : 2010 April 29 - 04 : 21
    select_datetime   : 2010 April 29  04  21  ( no dash no colon)
    
    :discard_hour => true
    f.datetime_select : 2010 April 29 
    select_datetime   : 2010 April 29  31 
    
    :discard_month => true
    f.datetime_select : 2010 - 04 : 21
    select_datetime   : 2010 29 04  21
    
    
    
    
    with patch
    =============
    no options
    f.datetime_select : 2010 April 29 - 04 : 21
    select_datetime   : 2010 April 29 - 00 : 21
    
    :discard_hour => true
    f.datetime_select : 2010 April 29 
    select_datetime   : 2010 April 29 
    
    :discard_month => true
    f.datetime_select : 2010 - 04 : 21
    select_datetime   : 2010 - 00 : 21
    

    Similar type of inconsistencies have been fixed for date_select and time_select.

    If you want to test some of these then you can put following code in your erb .
    http://gist.github.com/383178

    formatting was getting messed up hence I used gist.

    April 29th, 2010 @ 06:14 AM

  8. Repository
    Repository
    • State changed from open to resolved

    (from [68c96fad55fb13164e339426d7f1cbc88d4ccc8b]) Fix form builder and form helpers inconsistencies [#4432 datetime_select and select_datetime inconsistent for various options state:resolved]

    • datetime_select and select_datetime should be consistent as much as possible
    • date_select and select_date should be consistent as much as possible
    • time_select and select_time should be consistent as much as possible

    Signed-off-by: José Valim jose.valim@gmail.com
    http://github.com/rails/rails/commit/68c96fad55fb13164e339426d7f1cb...

    April 29th, 2010 @ 12:44 PM

  9. Santiago Pastorino
    Santiago Pastorino
    • Milestone set to 2.3.6
    • State changed from resolved to open

    Well done Neeraj Singh can you do the same for 2.3 stable?

    April 29th, 2010 @ 03:27 PM

  10. Neeraj Singh
    Neeraj Singh

    Hey Santiago,

    Attached is patch back ported for 2-3-stable branch.

    April 29th, 2010 @ 07:55 PM

  11. Santiago Pastorino
    Santiago Pastorino
    • Milestone cleared.
    • State changed from open to resolved

    Neeraj sorry, i didn't know that José said to you to not do the backport.
    Perhaps on 2.4 this could be fixed :P.

    April 29th, 2010 @ 08:18 PM

  12. Neeraj Singh
    Neeraj Singh

    Attached is patch against rails3. I forgot to remove a statement from the last patch.

    April 29th, 2010 @ 08:22 PM

  13. José Valim
    José Valim
    • State changed from resolved to open
    • Assigned user changed from Santiago Pastorino to José Valim

    April 29th, 2010 @ 09:27 PM

  14. Repository
  15. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Low

    October 15th, 2010 @ 11:01 PM