Time型のヘルパ

select_timeは面倒でdatetime_selectは日付が消せないので
time_selectを作るかと思ったのですがdatetime_selectから日付が消せるようにしてみる

この辺を参考に

  • jdate_helper

http://d.hatena.ne.jp/naoya_t/20060210/1139521526

消えるとです。感動です

<%= datetime_select 'businesshour', 'am', :discard_year => true, :discard_month => true, :discard_day => true %>

しかし...
[yyyy▼]-[hh▼]-[mm▼]
ってオイ

[file:/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_view/helpers/date_helper.rb]
287 datetime_select = select_year(datetime, options_with_prefix.call(1))
288 datetime_select << select_month(datetime, options_with_prefix.call(2)) unless options[:discard_month]
289 datetime_select << select_day(datetime, options_with_prefix.call(3)) unless options[:discard_day] || options[:discard_month]
290 datetime_select << ' — ' + select_hour(datetime, options_with_prefix.call(4)) unless options[:discard_hour]
291 datetime_select << ' : ' + select_minute(datetime, options_with_prefix.call(5)) unless options[:discard_minute] || options[:discard_hour]

ぁぅ...取りあえず納期もあるので治す
治したというわけでパッチ

287c287,288< datetime_select = select_year(datetime, options_with_prefix.call(1))

    • -

> datetime_select = ""
> datetime_select << select_year(datetime, options_with_prefix.call(1)) unless options[:discard_year]
290c291,292< datetime_select << ' — ' + select_hour(datetime, options_with_prefix.call(4)) unless options[:discard_hour]

    • -

> datetime_select << ' — ' if datetime_select.nil?
> datetime_select << select_hour(datetime, options_with_prefix.call(4)) unless options[:discard_hour]

取りあえず消えるようにして、時以前に何もselectタグが発生していなければ—を取る様にした
全部discardしてしまうお馬鹿さん避けは無い
そのへんまとめてunit_testも加えたら良いのだな...やっつけでごめん

todo:アップデートしたら治るのか調べて治らないならバグ報告をする
続く