Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/app/helpers/public_helper.rb b/app/helpers/public_helper.rb
- index 411b67819..26b4264bf 100644
- --- a/app/helpers/public_helper.rb
- +++ b/app/helpers/public_helper.rb
- @@ -237,66 +237,39 @@ HTML
- HTML
- end
- - def month_select_tag(id, date, time_zone)
- - current_zone = Time.zone
- - Time.zone = time_zone
- - selected_month = date.present? ? Time.utc(date.year, date.month, date.day, date.hour, date.min, 0).in_time_zone.month : (Time.now.in_time_zone +1.hour).month
- - Time.zone = current_zone
- + def date_for_select_tag(date, time_zone)
- + date = Time.now.in_time_zone + 1.day unless date.present?
- + date.in_time_zone(time_zone)
- + end
- - return select_tag(id, options_for_select([["Jan", 1], ["Feb", 2], ["Mar", 3], ["Apr", 4], ["May", 5], ["Jun", 6], ["Jul", 7],
- - ["Aug", 8], ["Sep", 9], ["Oct", 10], ["Nov", 11], ["Dec", 12]], selected_month), :class => 'time-select')
- + def month_select_tag(id, date, time_zone)
- + selected_month = date_for_select_tag(date, time_zone).month
- + month_options = Date::ABBR_MONTHNAMES.compact.each_with_index.map{ |month, i| [month, i] }
- + select_tag(id, options_for_select(month_options, selected_month), :class => 'time-select')
- end
- def day_select_tag(id, date, time_zone)
- - current_zone = Time.zone
- - Time.zone = time_zone
- - selected_day = date.present? ? Time.utc(date.year, date.month, date.day, date.hour, date.min, 0).in_time_zone.day : (Time.now.in_time_zone +1.hour).day
- - Time.zone = current_zone
- -
- - days = []
- - (1..31).each do |i|
- - days.push(i)
- - end
- - return select_tag(id, options_for_select(days, selected_day), :class => 'time-select')
- + selected_day = date_for_select_tag(date, time_zone).day
- + days = (1..31).to_a
- + select_tag(id, options_for_select(days, selected_day), :class => 'time-select')
- end
- def year_select_tag(id, date, time_zone)
- - current_zone = Time.zone
- - Time.zone = time_zone
- - selected_year = date.present? ? Time.utc(date.year, date.month, date.day, date.hour, date.min, 0).in_time_zone.year : (Time.now.in_time_zone +1.hour).year
- - Time.zone = current_zone
- -
- - years = []
- - (Time.now.year..Time.now.year + 2).each do |i|
- - years.push(i)
- - end
- - return select_tag(id, options_for_select(years, selected_year), :class => 'time-select')
- + selected_year = date_for_select_tag(date, time_zone).year
- + years = (Time.now.year..Time.now.year + 2).to_a
- + select_tag(id, options_for_select(years, selected_year), :class => 'time-select')
- end
- def hour_select_tag(id, date, time_zone)
- - current_zone = Time.zone
- - Time.zone = time_zone
- - selected_hour = date.present? ? Time.utc(date.year, date.month, date.day, date.hour, date.min, 0).in_time_zone.hour : (Time.now.in_time_zone +1.hour).hour
- - Time.zone = current_zone
- -
- - hours = []
- - (0..23).each do |i|
- - hours.push(["%02d" % i, i])
- - end
- - return select_tag(id, options_for_select(hours, selected_hour), :class => 'time-select')
- + selected_hour = date_for_select_tag(date, time_zone).hour
- + hours = (0..23).map{ |i| ['%02d' % i, i] }
- + select_tag(id, options_for_select(hours, selected_hour), :class => 'time-select')
- end
- def minute_select_tag(id, date, time_zone)
- - current_zone = Time.zone
- - Time.zone = time_zone
- - selected_min = date.present? ? Time.utc(date.year, date.month, date.day, date.hour, date.min, 0).in_time_zone.min : (Time.now.in_time_zone +1.hour).min
- - Time.zone = current_zone
- -
- - minutes = []
- - (0..59).each do |i|
- - minutes.push(["%02d" % i, i])
- - end
- - return select_tag(id, options_for_select(minutes, selected_min), :class => 'time-select')
- + selected_min = date_for_select_tag(date, time_zone).min
- + minutes = (0..59).map{ |i| ['%02d' % i, i] }
- + select_tag(id, options_for_select(minutes, selected_min), :class => 'time-select')
- end
- def upgrade_path(protocol, plan_id, source)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement