Checks cyclic holidays and checks if the requested year is hit within the
cycles.

@param aHoliday
Holiday
@param nYear
the year to check against
@return is valid
345827
private static boolean _isValidForCycle (@Nonnull final Holiday aHoliday, final int nYear)
  {
    final String sEvery = aHoliday.getEvery ();
    if (sEvery != null && !"EVERY_YEAR".equals (sEvery))
    {
      if ("ODD_YEARS".equals (sEvery))
        return nYear % 2 != 0;
      if ("EVEN_YEARS".equals (sEvery))
        return nYear % 2 == 0;

      if (aHoliday.getValidFrom () != null)
      {
        int nCycleYears = 0;
        if ("2_YEARS".equalsIgnoreCase (sEvery))
          nCycleYears = 2;
        else
          if ("3_YEARS".equalsIgnoreCase (sEvery))
            nCycleYears = 3;
          else
            if ("4_YEARS".equalsIgnoreCase (sEvery))
              nCycleYears = 4;
            else
              if ("5_YEARS".equalsIgnoreCase (sEvery))
                nCycleYears = 5;
              else
                if ("6_YEARS".equalsIgnoreCase (sEvery))
                  nCycleYears = 6;
                else
                  throw new IllegalArgumentException ("Cannot handle unknown cycle type '" + sEvery + "'.");

        return (nYear - aHoliday.getValidFrom ().intValue ()) % nCycleYears == 0;
      }
    }
    return true;
  }
936207
def is_holiday(self, date, division=None):
        
        return date in (holiday['date'] for holiday in self.get_holidays(division=division))
412763
public void seekToHoliday(String holidayString, String direction, String seekAmount) {
    Holiday holiday = Holiday.valueOf(holidayString);
    assert(holiday != null);
    
    seekToIcsEvent(HOLIDAY_ICS_FILE, holiday.getSummary(), direction, seekAmount);
  }
529870
def thanksgiving(year, country='usa'):
    ''''''
    if country == 'usa':
        if year in [1940, 1941]:
            return nth_day_of_month(3, THU, NOV, year)
        elif year == 1939:
            return nth_day_of_month(4, THU, NOV, year)
        else:
            return nth_day_of_month(0, THU, NOV, year)

    if country == 'canada':
        return nth_day_of_month(2, MON, OCT, year)
1121850
@Override
  public void parse (final int nYear, final HolidayMap aHolidayMap, final Holidays aConfig)
  {
    for (final ChristianHoliday aChristianHoliday : aConfig.getChristianHoliday ())
    {
      if (!isValid (aChristianHoliday, nYear))
        continue;

      ChronoLocalDate aEasterSunday;
      if (aChristianHoliday.getChronology () == ChronologyType.JULIAN)
        aEasterSunday = getJulianEasterSunday (nYear);
      else
        if (aChristianHoliday.getChronology () == ChronologyType.GREGORIAN)
          aEasterSunday = getGregorianEasterSunday (nYear);
        else
          aEasterSunday = getEasterSunday (nYear);

      switch (aChristianHoliday.getType ())
      {
        case EASTER:
          break;
        case CLEAN_MONDAY:
        case SHROVE_MONDAY:
          aEasterSunday = aEasterSunday.minus (48, ChronoUnit.DAYS);
          break;
        case MARDI_GRAS:
        case CARNIVAL:
          aEasterSunday = aEasterSunday.minus (47, ChronoUnit.DAYS);
          break;
        case ASH_WEDNESDAY:
          aEasterSunday = aEasterSunday.minus (46, ChronoUnit.DAYS);
          break;
        case MAUNDY_THURSDAY:
          aEasterSunday = aEasterSunday.minus (3, ChronoUnit.DAYS);
          break;
        case GOOD_FRIDAY:
          aEasterSunday = aEasterSunday.minus (2, ChronoUnit.DAYS);
          break;
        case EASTER_SATURDAY:
          aEasterSunday = aEasterSunday.minus (1, ChronoUnit.DAYS);
          break;
        case EASTER_MONDAY:
          aEasterSunday = aEasterSunday.plus (1, ChronoUnit.DAYS);
          break;
        case EASTER_TUESDAY:
          aEasterSunday = aEasterSunday.plus (2, ChronoUnit.DAYS);
          break;
        case GENERAL_PRAYER_DAY:
          aEasterSunday = aEasterSunday.plus (26, ChronoUnit.DAYS);
          break;
        case ASCENSION_DAY:
          aEasterSunday = aEasterSunday.plus (39, ChronoUnit.DAYS);
          break;
        case PENTECOST:
        case WHIT_SUNDAY:
          aEasterSunday = aEasterSunday.plus (49, ChronoUnit.DAYS);
          break;
        case WHIT_MONDAY:
        case PENTECOST_MONDAY:
          aEasterSunday = aEasterSunday.plus (50, ChronoUnit.DAYS);
          break;
        case CORPUS_CHRISTI:
          aEasterSunday = aEasterSunday.plus (60, ChronoUnit.DAYS);
          break;
        case SACRED_HEART:
          aEasterSunday = aEasterSunday.plus (68, ChronoUnit.DAYS);
          break;
        default:
          throw new IllegalArgumentException ("Unknown christian holiday type " + aChristianHoliday.getType ());
      }
      final LocalDate aConvertedDate = LocalDate.from (aEasterSunday);
      final IHolidayType aType = XMLHolidayHelper.getType (aChristianHoliday.getLocalizedType ());
      final String sPropertiesKey = "christian." + aChristianHoliday.getType ().name ();
      addChrstianHoliday (aConvertedDate, sPropertiesKey, aType, aHolidayMap);
    }
  }
129459
function(nYear) {
        var yrPattern = YAHOO.widget.CalendarNavigator.YR_PATTERN;
        if (YAHOO.lang.isNumber(nYear) && yrPattern.test(nYear+"")) {
            this._year = nYear;
        }
        this._updateYearUI();
    }
926825
public void parse (final int nYear, final HolidayMap aHolidayMap, final Holidays aConfig)
  {
    for (final FixedWeekdayBetweenFixed aFixedWeekdayBetweenFixed : aConfig.getFixedWeekdayBetweenFixed ())
    {
      if (!isValid (aFixedWeekdayBetweenFixed, nYear))
        continue;

      final DayOfWeek nExpectedWeekday = XMLHolidayHelper.getWeekday (aFixedWeekdayBetweenFixed.getWeekday ());
      LocalDate aFrom = XMLHolidayHelper.create (nYear, aFixedWeekdayBetweenFixed.getFrom ());
      final LocalDate aTo = XMLHolidayHelper.create (nYear, aFixedWeekdayBetweenFixed.getTo ());
      LocalDate aResult = null;
      while (!aFrom.isAfter (aTo))
      {
        if (aFrom.getDayOfWeek () == nExpectedWeekday)
        {
          aResult = aFrom;
          break;
        }
        aFrom = aFrom.plusDays (1);
      }

      if (aResult != null)
      {
        final IHolidayType aType = XMLHolidayHelper.getType (aFixedWeekdayBetweenFixed.getLocalizedType ());
        final String sPropertyKey = aFixedWeekdayBetweenFixed.getDescriptionPropertiesKey ();
        aHolidayMap.add (aResult, new ResourceBundleHoliday (aType, sPropertyKey));
      }
    }
  }
720711
public boolean isWorkingDay(Day day)
   {
      DayType value = getWorkingDay(day);
      boolean result;

      if (value == DayType.DEFAULT)
      {
         ProjectCalendar cal = getParent();
         if (cal != null)
         {
            result = cal.isWorkingDay(day);
         }
         else
         {
            result = (day != Day.SATURDAY && day != Day.SUNDAY);
         }
      }
      else
      {
         result = (value == DayType.WORKING);
      }

      return (result);
   }
541016
public static boolean isBirthday(CharSequence value) {
		if (isMactchRegex(BIRTHDAY, value)) {
			Matcher matcher = BIRTHDAY.matcher(value);
			if (matcher.find()) {
				int year = Integer.parseInt(matcher.group(1));
				int month = Integer.parseInt(matcher.group(3));
				int day = Integer.parseInt(matcher.group(5));
				return isBirthday(year, month, day);
			}
		}
		return false;
	}
527130
public HolidayMap getHolidays (final int nYear, @Nullable final String... aArgs)
  {
    return _getHolidays (nYear, m_aConfiguration, aArgs);
  }
798602
def get_calendar_holidays(self, year):
        
        # Unshifted days are here:
        days = super(ChineseNewYearCalendar, self).get_calendar_holidays(year)
        if self.shift_sunday_holidays:
            days_to_inspect = copy(days)
            for day_shifted in self.get_shifted_holidays(days_to_inspect):
                days.append(day_shifted)
        return days
342209
public void parse (final int nYear, final HolidayMap aHolidayMap, final Holidays aConfig)
  {
    for (final RelativeToEasterSunday aDay : aConfig.getRelativeToEasterSunday ())
    {
      if (!isValid (aDay, nYear))
        continue;
      final ChronoLocalDate aEasterSunday = getEasterSunday (nYear, aDay.getChronology ());
      aEasterSunday.plus (aDay.getDays (), ChronoUnit.DAYS);
      final String sPropertiesKey = "christian." + aDay.getDescriptionPropertiesKey ();
      addChrstianHoliday (aEasterSunday,
                          sPropertiesKey,
                          XMLHolidayHelper.getType (aDay.getLocalizedType ()),
                          aHolidayMap);
    }
  }
459171
private static int[] getHijrahDateInfo(long gregorianDays) {
        int era, year, month, date, dayOfWeek, dayOfYear;

        int cycleNumber, yearInCycle, dayOfCycle;

        long epochDay = gregorianDays - HIJRAH_JAN_1_1_GREGORIAN_DAY;

        if (epochDay >= 0) {
            cycleNumber = getCycleNumber(epochDay); // 0 - 99.
            dayOfCycle = getDayOfCycle(epochDay, cycleNumber); // 0 - 10631.
            yearInCycle = getYearInCycle(cycleNumber, dayOfCycle); // 0 - 29.
            dayOfYear = getDayOfYear(cycleNumber, dayOfCycle, yearInCycle);
            // 0 - 354/355
            year = cycleNumber * 30 + yearInCycle + 1; // 1-based year.
            month = getMonthOfYear(dayOfYear, year); // 0-based month-of-year
            date = getDayOfMonth(dayOfYear, month, year); // 0-based date
            ++date; // Convert from 0-based to 1-based
            era = HijrahEra.AH.getValue();
        } else {
            cycleNumber = (int) epochDay / 10631; // 0 or negative number.
            dayOfCycle = (int) epochDay % 10631; // -10630 - 0.
            if (dayOfCycle == 0) {
                dayOfCycle = -10631;
                cycleNumber++;
            }
            yearInCycle = getYearInCycle(cycleNumber, dayOfCycle); // 0 - 29.
            dayOfYear = getDayOfYear(cycleNumber, dayOfCycle, yearInCycle);
            year = cycleNumber * 30 - yearInCycle; // negative number.
            year = 1 - year;
            dayOfYear = (isLeapYear(year) ? (dayOfYear + 355)
                    : (dayOfYear + 354));
            month = getMonthOfYear(dayOfYear, year);
            date = getDayOfMonth(dayOfYear, month, year);
            ++date; // Convert from 0-based to 1-based
            era = HijrahEra.BEFORE_AH.getValue();
        }
        // Hijrah day zero is a Friday
        dayOfWeek = (int) ((epochDay + 5) % 7);
        dayOfWeek += (dayOfWeek <= 0) ? 7 : 0;

        int dateInfo[] = new int[6];
        dateInfo[0] = era;
        dateInfo[1] = year;
        dateInfo[2] = month + 1; // change to 1-based.
        dateInfo[3] = date;
        dateInfo[4] = dayOfYear + 1; // change to 1-based.
        dateInfo[5] = dayOfWeek;
        return dateInfo;
    }
1073368
@Override
    HijrahDate plusYears(long years) {
        if (years == 0) {
            return this;
        }
        int newYear = Jdk8Methods.safeAdd(this.yearOfEra, (int)years);
        return HijrahDate.of(this.era, newYear, this.monthOfYear, this.dayOfMonth);
    }
625018
public static LocalDate getGregorianEasterSunday (final int nYear)
  {
    final int a = nYear % 19;
    final int b = nYear / 100;
    final int c = nYear % 100;
    final int d = b / 4;
    final int e = b % 4;
    final int f = (b + 8) / 25;
    final int g = (b - f + 1) / 3;
    final int h = (19 * a + b - d - g + 15) % 30;
    final int i = c / 4;
    final int j = c % 4;
    final int k = (32 + 2 * e + 2 * i - h - j) % 7;
    final int l = (a + 11 * h + 22 * k) / 451;
    final int x = h + k - 7 * l + 114;
    final int nMonth = x / 31;
    final int nDay = (x % 31) + 1;
    return LocalDate.of (nYear, (nMonth == 3 ? Month.MARCH : Month.APRIL), nDay);
  }
259312
public boolean match(GregorianCalendar calendar, boolean isMatchSecond) {
		final int second = calendar.get(Calendar.SECOND);
		final int minute = calendar.get(Calendar.MINUTE);
		final int hour = calendar.get(Calendar.HOUR_OF_DAY);
		final int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
		final int month = calendar.get(Calendar.MONTH) + 1;// 月份从1开始
		final int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK) - 1; // 星期从0开始，0和7都表示周日
		final int year = calendar.get(Calendar.YEAR);

		boolean eval;
		for (int i = 0; i < matcherSize; i++) {
			eval = (isMatchSecond ? secondMatchers.get(i).match(second) : true) // 匹配秒（非秒匹配模式下始终返回true）
					&& minuteMatchers.get(i).match(minute)// 匹配分
					&& hourMatchers.get(i).match(hour)// 匹配时
					&& isMatchDayOfMonth(dayOfMonthMatchers.get(i), dayOfMonth, month, calendar.isLeapYear(year))// 匹配日
					&& monthMatchers.get(i).match(month) // 匹配月
					&& dayOfWeekMatchers.get(i).match(dayOfWeek)// 匹配周
					&& isMatch(yearMatchers, i, year);// 匹配年
			if (eval) {
				return true;
			}
		}
		return false;
	}
53319
public function calculateHolidaysForYear($year, $region, DateTimeZone $timezone = null)
    {
        $this->init();
        if (!isset($this->holidayProviders[$region])) {
            throw new HolidayException('Invalid location alias: '.$region);
        }
        $holidays = $this->holidayProviders[$region]->calculateHolidaysForYear($year, $timezone);

        return $holidays;
    }