def parse_time
timing = Array.new(5, '*')
case @time
when Whenever.seconds(0, :seconds)...Whenever.seconds(1, :minute)
raise ArgumentError, "Time must be in minutes or higher"
when Whenever.seconds(1, :minute)...Whenever.seconds(1, :hour)
minute_frequency = @time / 60
timing[0] = comma_separated_timing(minute_frequency, 59, @at || 0)
when Whenever.seconds(1, :hour)...Whenever.seconds(1, :day)
hour_frequency = (@time / 60 / 60).round
timing[0] = @at.is_a?(Time) ? @at.min : @at
timing[1] = comma_separated_timing(hour_frequency, 23)
when Whenever.seconds(1, :day)...Whenever.seconds(1, :month)
day_frequency = (@time / 24 / 60 / 60).round
timing[0] = @at.is_a?(Time) ? @at.min : 0
timing[1] = @at.is_a?(Time) ? @at.hour : @at
timing[2] = comma_separated_timing(day_frequency, 31, 1)
when Whenever.seconds(1, :month)..Whenever.seconds(12, :months)
month_frequency = (@time / 30 / 24 / 60 / 60).round
timing[0] = @at.is_a?(Time) ? @at.min : 0
timing[1] = @at.is_a?(Time) ? @at.hour : 0
timing[2] = if @at.is_a?(Time)
day_given? ? @at.day : 1
else
@at.zero? ? 1 : @at
end
timing[3] = comma_separated_timing(month_frequency, 12, 1)
else
return parse_as_string
end
timing.join(' ')
end