module Holidays
  module DateCalculator
    # Copied from https://github.com/sunsidew/ruby_lunardate
    # Graciously allowed by JeeWoong Yang (https://github.com/sunsidew)
    class LunarDate
      attr_accessor :year, :month, :day

      def to_solar(year, month, day, region)
        days = 0
        year_diff = year - 1900
        year_info = CALENDAR_YEAR_INFO_MAP[region]

        year_diff.times do |year_idx|
          days += year_info[year_idx][0]
        end

        (month - 1).times do |month_idx|
          total, _normal, _leap = lunardays_for_type(year_info[year_diff][month_idx + 1])
          days += total
        end

        days += (day - 1)

        SOLAR_START_DATE + days
      end

      def lunardays_for_type(month_type)
        LUNARDAYS_FOR_MONTHTYPE[month_type]
      end

      def to_s
        format('%4d%02d%02d', year, month, day)
      end

      private

      VIETNAMESE_LUNAR_YEAR_INFO = [
        [384, 1, 2, 1, 1, 2, 1, 2, 4, 2, 2, 1, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1].freeze,
        [355, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2].freeze,
        [383, 1, 2, 1, 2, 3, 2, 1, 1, 2, 2, 1, 2].freeze,
        [354, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1].freeze,
        [355, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [384, 1, 2, 2, 5, 1, 2, 1, 2, 1, 2, 1, 2].freeze,
        [354, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2].freeze,
        [384, 1, 4, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1].freeze,
        [384, 2, 1, 2, 1, 1, 4, 1, 2, 2, 1, 2, 2].freeze,
        [354, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2].freeze,
        [354, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2].freeze,
        [384, 2, 2, 1, 2, 4, 1, 2, 1, 2, 1, 1, 2].freeze,
        [355, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2].freeze,
        [354, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1].freeze,
        [384, 2, 3, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1].freeze,
        [355, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2].freeze,
        [384, 1, 2, 1, 1, 2, 1, 4, 2, 2, 1, 2, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2].freeze,
        [354, 2, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2].freeze,
        [384, 2, 1, 2, 2, 3, 2, 1, 1, 2, 1, 2, 2].freeze,
        [354, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2].freeze,
        [354, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 1].freeze,
        [385, 2, 1, 2, 4, 2, 1, 2, 2, 1, 2, 1, 2].freeze,
        [354, 1, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1].freeze,
        [355, 2, 1, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2].freeze,
        [384, 1, 4, 1, 2, 1, 1, 2, 2, 1, 2, 2, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2].freeze,
        [383, 1, 2, 2, 1, 1, 4, 1, 2, 1, 2, 2, 1].freeze,
        [354, 2, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 1].freeze,
        [355, 2, 2, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2].freeze,
        [384, 1, 2, 2, 1, 6, 1, 2, 1, 2, 1, 1, 2].freeze,
        [355, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 2].freeze,
        [354, 1, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1].freeze,
        [384, 2, 1, 5, 1, 2, 1, 2, 1, 2, 2, 2, 1].freeze,
        [354, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2, 1].freeze,
        [384, 2, 2, 1, 1, 2, 1, 5, 1, 2, 2, 1, 2].freeze,
        [354, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [354, 2, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1].freeze,
        [384, 2, 2, 1, 2, 2, 5, 1, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2].freeze,
        [355, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2].freeze,
        [384, 1, 1, 2, 5, 1, 2, 1, 2, 2, 1, 2, 2].freeze,
        [354, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2, 1, 2].freeze,
        [354, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2].freeze,
        [384, 2, 4, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2].freeze,
        [354, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [384, 2, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1, 2].freeze,
        [354, 2, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2].freeze,
        [384, 1, 2, 1, 2, 5, 2, 1, 2, 1, 2, 1, 2].freeze,
        [355, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 2].freeze,
        [354, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2].freeze,
        [384, 2, 1, 5, 1, 1, 2, 1, 2, 1, 2, 2, 2].freeze,
        [354, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2].freeze,
        [384, 2, 1, 2, 1, 2, 1, 1, 4, 2, 1, 2, 2].freeze,
        [354, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [354, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1].freeze,
        [384, 2, 1, 2, 1, 2, 4, 2, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1].freeze,
        [384, 2, 1, 2, 3, 2, 1, 2, 1, 2, 2, 2, 1].freeze,
        [355, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2].freeze,
        [354, 1, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2].freeze,
        [383, 1, 2, 4, 2, 1, 1, 2, 1, 1, 2, 2, 1].freeze,
        [355, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [384, 1, 2, 2, 1, 2, 1, 4, 2, 1, 2, 1, 2].freeze,
        [354, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2].freeze,
        [384, 1, 2, 1, 1, 4, 2, 1, 2, 2, 2, 1, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1].freeze,
        [354, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2, 1].freeze,
        [384, 2, 2, 1, 4, 1, 2, 1, 1, 2, 2, 1, 2].freeze,
        [354, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2].freeze,
        [384, 2, 2, 1, 2, 1, 2, 1, 4, 2, 1, 1, 2].freeze,
        [354, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 1].freeze,
        [355, 2, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1].freeze,
        [384, 2, 1, 1, 2, 1, 6, 1, 2, 2, 1, 2, 1].freeze,
        [355, 2, 1, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2].freeze,
        [384, 2, 1, 2, 3, 2, 1, 1, 2, 2, 1, 2, 2].freeze,
        [354, 2, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2].freeze,
        [384, 2, 1, 2, 2, 1, 1, 2, 1, 1, 4, 2, 2].freeze,
        [354, 1, 2, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2].freeze,
        [354, 1, 2, 2, 1, 2, 2, 1, 2, 1, 2, 1, 1].freeze,
        [385, 2, 1, 2, 2, 1, 4, 2, 2, 1, 2, 1, 2].freeze,
        [354, 1, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1].freeze,
        [355, 2, 1, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2].freeze,
        [384, 1, 2, 1, 1, 4, 1, 2, 2, 1, 2, 2, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2].freeze,
        [354, 1, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2].freeze,
        [383, 1, 2, 4, 2, 1, 2, 1, 1, 2, 1, 2, 1].freeze,
        [355, 2, 2, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2].freeze,
        [384, 1, 2, 2, 1, 2, 2, 1, 4, 2, 1, 1, 2].freeze,
        [355, 1, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2].freeze,
        [354, 1, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1].freeze,
        [384, 2, 1, 1, 2, 3, 2, 2, 1, 2, 2, 2, 1].freeze,
        [354, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2, 1].freeze,
        [354, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1].freeze,
        [384, 2, 2, 2, 3, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [354, 2, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1].freeze,
        [355, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2].freeze,
        [384, 1, 4, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2].freeze,
        [354, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1].freeze,
        [385, 2, 1, 2, 1, 2, 1, 4, 2, 2, 1, 2, 2].freeze,
        [354, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2, 1, 2].freeze,
        [354, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2].freeze,
        [384, 2, 2, 1, 1, 4, 1, 2, 1, 2, 1, 2, 2].freeze,
        [354, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [354, 2, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 1].freeze,
        [384, 2, 1, 6, 2, 1, 2, 1, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2].freeze,
        [384, 1, 2, 1, 2, 1, 2, 1, 2, 4, 2, 1, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 2, 2, 2, 1, 2, 1].freeze,
        [355, 2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2].freeze,
        [355, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 2].freeze,
        [354, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2].freeze,
        [354, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [384, 2, 1, 2, 4, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [354, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2].freeze,
        [384, 1, 4, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1].freeze,
        [384, 2, 1, 2, 1, 1, 4, 2, 1, 2, 2, 2, 1].freeze,
        [355, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2].freeze,
        [354, 1, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2].freeze,
        [383, 1, 2, 2, 1, 4, 1, 2, 1, 1, 2, 2, 1].freeze,
        [355, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2].freeze,
        [354, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1].freeze,
        [384, 2, 1, 4, 2, 1, 2, 2, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2].freeze,
        [384, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 4, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1].freeze,
        [354, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2].freeze,
        [384, 2, 2, 1, 2, 1, 5, 1, 1, 2, 2, 1, 2].freeze,
        [354, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2].freeze,
        [354, 2, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1].freeze,
        [384, 2, 2, 1, 2, 4, 2, 1, 2, 1, 2, 1, 1].freeze,
        [355, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2].freeze,
        [384, 1, 4, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2].freeze,
        [384, 2, 1, 2, 1, 1, 2, 3, 2, 1, 2, 2, 2].freeze,
        [354, 2, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2].freeze,
        [354, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2].freeze,
        [384, 2, 1, 2, 2, 5, 1, 2, 1, 1, 2, 1, 2].freeze,
        [354, 1, 2, 2, 1, 2, 2, 1, 2, 1, 2, 1, 1].freeze,
        [355, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1].freeze
      ].freeze

      KOREAN_LUNAR_YEAR_INFO = [
        [384, 1, 2, 1, 1, 2, 1, 2, 4, 2, 2, 1, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1].freeze,
        [355, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2].freeze,
        [383, 1, 2, 1, 2, 3, 2, 1, 1, 2, 2, 1, 2].freeze,
        [354, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1].freeze,
        [355, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [384, 1, 2, 2, 5, 1, 2, 1, 2, 1, 2, 1, 2].freeze,
        [354, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2].freeze,
        [384, 1, 4, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1].freeze,
        [384, 2, 1, 2, 1, 1, 4, 1, 2, 2, 1, 2, 2].freeze,
        [354, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2].freeze,
        [354, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2].freeze,
        [384, 2, 2, 1, 2, 4, 1, 2, 1, 2, 1, 1, 2].freeze,
        [355, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2].freeze,
        [354, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1].freeze,
        [384, 2, 3, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1].freeze,
        [355, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2].freeze,
        [384, 1, 2, 1, 1, 2, 1, 4, 2, 2, 1, 2, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2].freeze,
        [354, 2, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2].freeze,
        [384, 2, 1, 2, 2, 3, 2, 1, 1, 2, 1, 2, 2].freeze,
        [354, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2].freeze,
        [354, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 1].freeze,
        [385, 2, 1, 2, 4, 2, 1, 2, 2, 1, 2, 1, 2].freeze,
        [354, 1, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1].freeze,
        [355, 2, 1, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2].freeze,
        [384, 1, 4, 1, 2, 1, 1, 2, 2, 1, 2, 2, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2].freeze,
        [383, 1, 2, 2, 1, 1, 4, 1, 2, 1, 2, 2, 1].freeze,
        [354, 2, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 1].freeze,
        [355, 2, 2, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2].freeze,
        [384, 1, 2, 2, 1, 6, 1, 2, 1, 2, 1, 1, 2].freeze,
        [355, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 2].freeze,
        [354, 1, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1].freeze,
        [384, 2, 1, 5, 1, 2, 1, 2, 1, 2, 2, 2, 1].freeze,
        [354, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2, 1].freeze,
        [384, 2, 2, 1, 1, 2, 1, 5, 1, 2, 2, 1, 2].freeze,
        [354, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [354, 2, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1].freeze,
        [384, 2, 2, 1, 2, 2, 5, 1, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2].freeze,
        [355, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2].freeze,
        [384, 1, 1, 2, 5, 1, 2, 1, 2, 2, 1, 2, 2].freeze,
        [354, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2, 1, 2].freeze,
        [354, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2].freeze,
        [384, 2, 4, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2].freeze,
        [354, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [384, 2, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1, 2].freeze,
        [354, 2, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2].freeze,
        [384, 1, 2, 1, 2, 5, 2, 1, 2, 1, 2, 1, 2].freeze,
        [355, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 2].freeze,
        [354, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2].freeze,
        [384, 2, 1, 5, 1, 1, 2, 1, 2, 1, 2, 2, 2].freeze,
        [354, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2].freeze,
        [384, 2, 1, 2, 1, 2, 1, 1, 4, 2, 1, 2, 2].freeze,
        [354, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [354, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1].freeze,
        [384, 2, 1, 2, 1, 2, 4, 2, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1].freeze,
        [384, 2, 1, 2, 3, 2, 1, 2, 1, 2, 2, 2, 1].freeze,
        [355, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2].freeze,
        [354, 1, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2].freeze,
        [383, 1, 2, 4, 2, 1, 1, 2, 1, 1, 2, 2, 1].freeze,
        [355, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [384, 1, 2, 2, 1, 2, 1, 4, 2, 1, 2, 1, 2].freeze,
        [354, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2].freeze,
        [384, 1, 2, 1, 1, 4, 2, 1, 2, 2, 2, 1, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1].freeze,
        [354, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2, 1].freeze,
        [384, 2, 2, 1, 4, 1, 2, 1, 1, 2, 2, 1, 2].freeze,
        [354, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2].freeze,
        [384, 2, 2, 1, 2, 1, 2, 1, 4, 2, 1, 1, 2].freeze,
        [354, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 1].freeze,
        [355, 2, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1].freeze,
        [384, 2, 1, 1, 2, 1, 6, 1, 2, 2, 1, 2, 1].freeze,
        [355, 2, 1, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2].freeze,
        [384, 2, 1, 2, 3, 2, 1, 1, 2, 2, 1, 2, 2].freeze,
        [354, 2, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2].freeze,
        [384, 2, 1, 2, 2, 1, 1, 2, 1, 1, 4, 2, 2].freeze,
        [354, 1, 2, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2].freeze,
        [354, 1, 2, 2, 1, 2, 2, 1, 2, 1, 2, 1, 1].freeze,
        [385, 2, 1, 2, 2, 1, 4, 2, 2, 1, 2, 1, 2].freeze,
        [354, 1, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1].freeze,
        [355, 2, 1, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2].freeze,
        [384, 1, 2, 1, 1, 4, 1, 2, 2, 1, 2, 2, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2].freeze,
        [354, 1, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2].freeze,
        [383, 1, 2, 4, 2, 1, 2, 1, 1, 2, 1, 2, 1].freeze,
        [355, 2, 2, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2].freeze,
        [384, 1, 2, 2, 1, 2, 2, 1, 4, 2, 1, 1, 2].freeze,
        [355, 1, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2].freeze,
        [354, 1, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1].freeze,
        [384, 2, 1, 1, 2, 3, 2, 2, 1, 2, 2, 2, 1].freeze,
        [354, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2, 1].freeze,
        [354, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1].freeze,
        [384, 2, 2, 2, 3, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [354, 2, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1].freeze,
        [355, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2].freeze,
        [384, 1, 4, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2].freeze,
        [354, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1].freeze,
        [385, 2, 1, 2, 1, 2, 1, 4, 2, 2, 1, 2, 2].freeze,
        [354, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2, 1, 2].freeze,
        [354, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2].freeze,
        [384, 2, 2, 1, 1, 4, 1, 2, 1, 2, 1, 2, 2].freeze,
        [354, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [354, 2, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 1].freeze,
        [384, 2, 1, 6, 2, 1, 2, 1, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2].freeze,
        [384, 1, 2, 1, 2, 1, 2, 1, 2, 4, 2, 1, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 2, 2, 2, 1, 2, 1].freeze,
        [355, 2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2].freeze,
        [384, 1, 2, 1, 2, 3, 2, 1, 2, 1, 2, 2, 2].freeze,
        [354, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2].freeze,
        [354, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [384, 2, 1, 2, 4, 2, 1, 1, 2, 1, 2, 1, 2].freeze,
        [354, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2].freeze,
        [384, 1, 4, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1].freeze,
        [384, 2, 1, 2, 1, 1, 4, 2, 1, 2, 2, 2, 1].freeze,
        [355, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2].freeze,
        [354, 1, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2].freeze,
        [383, 1, 2, 2, 1, 4, 1, 2, 1, 1, 2, 2, 1].freeze,
        [355, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 2].freeze,
        [354, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1].freeze,
        [384, 2, 1, 4, 2, 1, 2, 2, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2].freeze,
        [384, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 4, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1].freeze,
        [354, 2, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2].freeze,
        [384, 2, 2, 1, 2, 1, 5, 1, 1, 2, 2, 1, 2].freeze,
        [354, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2].freeze,
        [354, 2, 2, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1].freeze,
        [384, 2, 2, 1, 2, 4, 2, 1, 2, 1, 2, 1, 1].freeze,
        [355, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 2, 1].freeze,
        [355, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2].freeze,
        [384, 1, 4, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2].freeze,
        [354, 1, 2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2].freeze,
        [384, 2, 1, 2, 1, 1, 2, 3, 2, 1, 2, 2, 2].freeze,
        [354, 2, 1, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2].freeze,
        [354, 2, 1, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2].freeze,
        [384, 2, 1, 2, 2, 5, 1, 2, 1, 1, 2, 1, 2].freeze,
        [354, 1, 2, 2, 1, 2, 2, 1, 2, 1, 2, 1, 1].freeze,
        [355, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1].freeze
      ].freeze

      MAX_YEAR_NUMBER = 150

      # Given the region, CALENDAR_YEAR_INFO_MAP looks up the date 
      # table and uses it in the calculation
      CALENDAR_YEAR_INFO_MAP = {
        kr: KOREAN_LUNAR_YEAR_INFO,
        vi: VIETNAMESE_LUNAR_YEAR_INFO
      }.freeze

      # Provides number of days per lunar month type.  Lunar months 
      # can be either 29 or 30 days long (29.5 days, rounded up or down). 
      # Keys 3 - 6 provide data for intercalary (leap month) occurrences. 
      # Format: [TOTAL, NORMAL, LEAP]
      LUNARDAYS_FOR_MONTHTYPE = {
        1 => [29, 29, 0],
        2 => [30, 30, 0],
        3 => [58, 29, 29],
        4 => [59, 30, 29],
        5 => [59, 29, 30],
        6 => [60, 30, 30]
      }.freeze

      # Provides the reference point for the Gregorian calendar and is
      # used in all calculations
      SOLAR_START_DATE = Date.new(1900, 1, 31).freeze

    end
  end
end
