Class: TimecopConsole::MainController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/timecop_console/main_controller.rb

Instance Method Summary collapse

Instance Method Details

#resetObject



27
28
29
30
# File 'app/controllers/timecop_console/main_controller.rb', line 27

def reset
  session[SESSION_KEY_NAME] = nil
  redirect_to :back
end

#updateObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/timecop_console/main_controller.rb', line 5

def update
  if date_select_format?
    year   = params['timecop']['current_time(1i)']
    month  = params['timecop']['current_time(2i)']
    day    = params['timecop']['current_time(3i)']
    hour   = params['timecop']['current_time(4i)']
    minute = params['timecop']['current_time(5i)']
    second = Time.now.sec
  else
    # backward compatible format
    year   = params[:year]
    month  = params[:month]
    day    = params[:day]
    hour   = params[:hour]
    minute = params[:min]
    second = params[:sec]
  end

  session[SESSION_KEY_NAME] = Time.local(year, month, day, hour, minute, second)
  redirect_to :back
end