Module: TaskManager::DeadlineCalculator

Included in:
Plan
Defined in:
lib/task-manager/deadline_calculator.rb

Instance Method Summary collapse

Instance Method Details

#calculate_deadline(type, opts) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/task-manager/deadline_calculator.rb', line 3

def calculate_deadline(type, opts)
  type = convert_type(type)
  opts.symbolize_keys!

  beginning = Time.now.send("beginning_of_#{type}")
  beginning.
    months_since(opts[:deadline_month].to_i).
    since(opts[:deadline_day].to_i * 24 * 60 * 60).
    since(opts[:deadline_hour].to_i * 60 * 60).
    since(opts[:deadline_minute].to_i * 60)
end