<commit_before>require_relative '../lib/zellers'

class Month
  attr_reader :month, :year
  WIDTH = 20

  def initialize(month, year)
    @month = month.to_i
    @year = year.to_i
  end

  def z
    z = Zellers.new(month, year)
  end

  def name
    names = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
    names.at(@month -1)
  end

  def date_header
    "#{name} #{year}".center(WIDTH).rstrip.concat("\n")
  end

  def week_header
    "Su Mo Tu We Th Fr Sa".concat("\n")
  end

  def month_length
    thirty_days = [9, 4, 6, 11]
    thirty_one_days = [1, 3, 5, 7, 8, 10, 12]

    if month == 2 and leap?
      29
    else
      28
    end

    if thirty_days.include? month
      30
    else
      31
    end
  end


  def to_s

    output = ""
    output << date_header
    output << week_header

    weeks = (1..month_length).to_a

    (z.start - 1).times {weeks.unshift("  ")}
<commit_msg>Changed constant WIDTH to MONTH_WIDTH<commit_after>require_relative '../lib/zellers'

class Month
  attr_reader :month, :year
  MONTH_WIDTH = 20

  def initialize(month, year)
    @month = month.to_i
    @year = year.to_i
  end

  def input_error_message
    <<EOS
Date not in acceptable format/range
`./cal.rb [MM] [YYYY]
EOS
  end



  def name
    names = ["January",
             "February",
             "March",
             "April",
             "May",
             "June",
             "July",
             "August",
             "September",
             "October",
             "November",
             "December"]
    names.at(@month - 1)
  end


  def leap

    if @year % 100 === 0 && @year % 400 === 0
      leap = true
    elsif @year % 4 === 0 && @year % 100 != 0
      leap = true
    else
      leap = false
    end
  end


  def date_header
    "#{name} #{year}".center(MONTH_WIDTH).rstrip.concat("\n")
  end

  def week_header
    "Su Mo Tu We Th Fr Sa".concat("\n")
  end

  def month_length
    thirty_days = [9, 4, 6, 11]

    if month == 2 and leap
      29
    elsif month == 2 and !leap
      28
    elsif thirty_days.include? month
      30
    else
      31
    end
  end

  def to_s

    z = Zellers.new(month, year)

    output = ""
    output << date_header
    output << week_header

    weeks = (1..month_length).to_a

    (z.start - 1).times {weeks.unshift("  ")}

{'fraction_non_alphanumeric': 0.13164556962025317, 'fraction_numerical': 0.026160337552742614, 'mean_word_length': 1.930778739184178, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6383051', 'n_tokens_mistral': 917, 'n_tokens_neox': 816, 'n_words': 234}