/*[deutsch]
<p>Subtrahiert die angegebenen Kalendertage von dieser Instanz. </p>

@param   days    calendar days to be subtracted
@return  result of subtraction
@throws  ArithmeticException in case of numerical overflow
@since   3.4/4.3
165115
public D minus(CalendarDays days) {

        return this.plus(CalendarDays.of(Math.negateExact(days.getAmount())));

    }
1101323
public void plusDays(long delta)
    {
        if (delta != 0)
        {
            long result = getDay() + delta;
            if (result >= 1 && result <= 28)
            {
                setDay((int) result);
            }
            else
            {
                ZonedDateTime zonedDateTime = ZonedDateTime.from(this);
                ZonedDateTime plusDays = zonedDateTime.plusDays(delta);
                set(plusDays);
            }
        }
    }
934599
public static String dateIncreaseByDay(String date, String fmt, int days) {
        return dateIncrease(date, fmt, Calendar.DATE, days);
    }
743559
public static Integer getDays(String days)
   {
      Integer result = null;
      if (days != null)
      {
         result = Integer.valueOf(Integer.parseInt(days, 2));
      }
      return (result);
   }
1356707
public function add_days($days)
    {
        
        if ($days < 0) {
            return $this->sub_days($days * -1);
        }
        
        if ($this->flag_jours_ouvres == true) {
            for ($d = 0; $d < $days;) {
                $this->time += self::$TIME2SEC['d'];
                $this->set_timestamp($this->time);
                
                if ($this->est_jours_ouvres()) {
                    $d++;
                }
            }
        }
        else {
            $this->time += $days * self::$TIME2SEC['d'];
            $this->set_timestamp($this->time);
        }
        
        return $this;
    }
483242
@Override
	public double getDaycount(LocalDate startDate, LocalDate endDate) {
		if(startDate.isAfter(endDate)) {
			return -getDaycount(endDate,startDate);
		}

		int startDateDay 	= startDate.getDayOfMonth();
		int startDateMonth 	= startDate.getMonthValue();
		int startDateYear 	= startDate.getYear();

		int endDateDay 		= endDate.getDayOfMonth();
		int endDateMonth 	= endDate.getMonthValue();
		int endDateYear 	= endDate.getYear();

		if(
				isEndOfMonth &&
				startDate.getMonth() == Month.FEBRUARY &&
				startDate.getDayOfMonth() == startDate.lengthOfMonth() &&
				endDate.getMonth() == Month.FEBRUARY &&
				endDate.getDayOfMonth() == endDate.lengthOfMonth()
				) {
			endDateDay = 30;
		}

		if(
				isEndOfMonth &&
				startDate.getMonth() == Month.FEBRUARY &&
				startDate.getDayOfMonth() == startDate.lengthOfMonth()
				) {
			startDateDay = 30;
		}

		if(endDateDay > 30 && startDateDay >= 30) {
			endDateDay = 30;
		}
		startDateDay = Math.min(startDateDay,30);

		return (endDateYear - startDateYear) * 360.0 + (endDateMonth - startDateMonth) * 30.0 + (endDateDay - startDateDay);
	}
954579
private void readDay(ProjectCalendar calendar, Project.Calendars.Calendar.WeekDays.WeekDay day, boolean readExceptionsFromDays)
   {
      BigInteger dayType = day.getDayType();
      if (dayType != null)
      {
         if (dayType.intValue() == 0)
         {
            if (readExceptionsFromDays)
            {
               readExceptionDay(calendar, day);
            }
         }
         else
         {
            readNormalDay(calendar, day);
         }
      }
   }
222038
public static Date addDays(long dt, int days)
    {
        Calendar c = getCalendar();
        if(dt > 0L)
            c.setTimeInMillis(dt);
        c.add(Calendar.DATE, days);
        return c.getTime();
    }
172778
public DateFuncSup subtract(DateSeperator d) {
                date.setTime(date.getTime() - d.parse());
                return this;
        }
580533
public static int subtractMonths(int date0, int date1) {
		if (date0 < date1) {
			return -subtractMonths(date1, date0);
		}
		// Start with an estimate.
		// Since no month has more than 31 days, the estimate is <= the true value.
		int m = (date0 - date1) / 31;
		for (;;) {
			int date2 = addMonths(date1, m);
			if (date2 >= date0) {
				return m;
			}
			int date3 = addMonths(date1, m + 1);
			if (date3 > date0) {
				return m;
			}
			++m;
		}
	}
1220341
public String getEasterSunday(int year, int days) {
		int K = year / 100;
		int M = 15 + ( ( 3 * K + 3 ) / 4 ) - ( ( 8 * K + 13 ) / 25 );
		int S = 2 - ( (3 * K + 3) / 4 );
		int A = year % 19;
		int D = ( 19 * A + M ) % 30;
		int R = ( D / 29) + ( ( D / 28 ) - ( D / 29 ) * ( A / 11 ) );
		int OG = 21 + D - R;
		int SZ = 7 - ( year + ( year / 4 ) + S ) % 7;
		int OE = 7 - ( OG - SZ ) % 7;
		int OS = OG + OE;
		
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
		Calendar c = Calendar.getInstance();
		String date;
		
		if( OS <= 31 ) {
			date = String.format("%04d-03-%02d", year, OS);
		}
		else{
			date = String.format("%04d-04-%02d", year, ( OS - 31 ) );
		}		
		try{
			c.setTime(formatter.parse(date));
			c.add(Calendar.DAY_OF_MONTH, days);
			date = formatter.format(c.getTime());
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return date;
	}
448384
public CalendarDateCalculator moveByDays(final int days) {
        setCurrentIncrement(days);
        getCurrentBusinessDate().add(Calendar.DAY_OF_MONTH, days);

        if (getHolidayHandler() != null) {
            setCurrentBusinessDate(getHolidayHandler().moveCurrentDate(this));
        }

        return this;
    }
460432
public static Day getDay(Integer day)
   {
      Day result = null;
      if (day != null)
      {
         result = DAY_ARRAY[day.intValue()];
      }
      return (result);
   }
701140
public static int calendarDay2Day(int day) {
        switch (day) {
            case Calendar.SUNDAY:
                return SU;
            case Calendar.MONDAY:
                return MO;
            case Calendar.TUESDAY:
                return TU;
            case Calendar.WEDNESDAY:
                return WE;
            case Calendar.THURSDAY:
                return TH;
            case Calendar.FRIDAY:
                return FR;
            case Calendar.SATURDAY:
                return SA;
            default:
                throw new RuntimeException("bad day of week: " + day);
        }
    }
1153307
public static Date plus(Date self, int days) {
        Calendar calendar = (Calendar) Calendar.getInstance().clone();
        calendar.setTime(self);
        calendar.add(Calendar.DAY_OF_YEAR, days);
        return calendar.getTime();
    }
183698
public static Date addDays(Date date, int numberOfDays) {
    return Date.from(date.toInstant().plus(numberOfDays, ChronoUnit.DAYS));
  }
546479
public CalendarQuarter minus(Years<CalendarUnit> years) {

        if (years.isEmpty()) {
            return this;
        }

        return CalendarQuarter.of(MathUtils.safeSubtract(this.year, years.getAmount()), this.quarter);

    }