lib/github_issue_stats.rb
#
# Computes the the beginning of the period based on the end of a period
#
Computes the the beginning of the period based on the end of a period
Computes the the beginning of the period based on the end of a period
def compute_previous_time(current_time, period)
    period_number, period_type = [period[0..-2], period[-1]]
    period_number = Integer(period_number)
    if period_type == "h"
      return current_time - period_number * 3600
    elsif period_type == "d"
      return current_time - period_number * 3600 * 24
    elsif period_type == "w"
      return current_time - period_number * 7 * 3600 * 24
    elsif period_type == "m"
      current_date = Date.new(current_time.year, current_time.month, current_time.day)
      temp_date = current_date
      for i in 1..period_number
        previous_date = temp_date.prev_month
        temp_date = previous_date
      end
      previous_time = Time.utc(previous_date.year, previous_date.month, previous_date.day, current_time.hour, current_time.min, current_time.sec)
    elsif period_type == "y"
      return Time.utc(current_time.year - period_number, current_time.month, current_time.day, current_time.hour, current_time.min, current_time.sec)
    else
    end
  end
def compute_previous_time ( current_time , period ) period_number , period_type = [ period [ 0 .. - 2 ] , period [ - 1 ] ] period_number = Integer ( period_number ) if period_type == "h" return current_time - period_number * 3600 elsif period_type == "d" return current_time - period_number * 3600 * 24 elsif period_type == "w" return current_time - period_number * 7 * 3600 * 24 elsif period_type == "m" current_date = Date . new ( current_time . year , current_time . month , current_time . day ) temp_date = current_date for i in 1 .. period_number previous_date = temp_date . prev_month temp_date = previous_date end previous_time = Time . utc ( previous_date . year , previous_date . month , previous_date . day , current_time . hour , current_time . min , current_time . sec ) elsif period_type == "y" return Time . utc ( current_time . year - period_number , current_time . month , current_time . day , current_time . hour , current_time . min , current_time . sec ) else end end
Computes the the beginning of the period based on the end of a period
Computes the the beginning of the period based on the end of a period
# TODO throw error
current_time
period