Class: Time

Inherits:
Object
  • Object
show all
Defined in:
lib/aws_helpers/common/time.rb

Class Method Summary collapse

Class Method Details

.subtract_period(time, options) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/aws_helpers/common/time.rb', line 4

def subtract_period(time, options)
  return time unless options

  hours = options[:hours]
  days = options[:days]
  months = options[:months]

  subtracted_time = time
  subtracted_time = subtracted_time - hours_to_seconds(hours.to_i) if hours
  subtracted_time = subtracted_time - days_to_seconds(days.to_i) if days
  subtracted_time = (subtracted_time.to_datetime << months.to_i).to_time if months
  subtracted_time
end