Find the month in the year of the birth of the first child.

@param int $year1
@param int $year2

@return Builder
352278
public function monthFirstChildQuery(int $year1 = -1, int $year2 = -1): Builder
    {
        $first_child_subquery = DB::table('link')
            ->join('dates', static function (JoinClause $join): void {
                $join
                    ->on('d_gid', '=', 'l_to')
                    ->on('d_file', '=', 'l_file')
                    ->where('d_julianday1', '<>', 0)
                    ->whereIn('d_month', ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC']);
            })
            ->where('l_file', '=', $this->tree->id())
            ->where('l_type', '=', 'CHIL')
            ->select(['l_from AS family_id', DB::raw('MIN(d_julianday1) AS min_birth_jd')])
            ->groupBy('family_id');

        $query = DB::table('link')
            ->join('dates', static function (JoinClause $join): void {
                $join
                    ->on('d_gid', '=', 'l_to')
                    ->on('d_file', '=', 'l_file');
            })
            ->joinSub($first_child_subquery, 'subquery', static function (JoinClause $join): void {
                $join
                    ->on('family_id', '=', 'l_from')
                    ->on('min_birth_jd', '=', 'd_julianday1');
            })
            ->where('link.l_file', '=', $this->tree->id())
            ->where('link.l_type', '=', 'CHIL')
            ->select(['d_month', DB::raw('COUNT(*) AS total')])
            ->groupBy(['d_month']);

        if ($year1 >= 0 && $year2 >= 0) {
            $query->whereBetween('d_year', [$year1, $year2]);
        }

        return $query;
    }
996855
public static Years<CalendarUnit> between(CalendarYear y1, CalendarYear y2) {

        return Years.ofGregorian(y2.getValue() - y1.getValue());

    }
979725
public static function ifIsBigDate($date1,$date2){

		if(strtotime($date1) > strtotime($date2)){
				return 1;
		}else if(strtotime($date1) == strtotime($date2)){
				return 0;
		}else{
				return -1;
		}
    }
919677
public static function gregorianToJd($month, $day, $year)
    {
        if ($year == 0) {
            return 0;
        } else {
            return self::$gregorian_calendar->ymdToJd($year, $month, $day);
        }
    }
322024
public function withYear(int $year) : YearMonth
    {
        if ($year === $this->year) {
            return $this;
        }

        Field\Year::check($year);

        return new YearMonth($year, $this->month);
    }
760215
public function setBirthdate(\DateTime $Birthdate = null)
    {
        $this->Birthdate = $Birthdate ? $Birthdate : null;

        return $this;
    }
459779
public static long subMonths(final Date date1, final Date date2) {

    Calendar calendar1 = buildCalendar(date1);
    int monthOfDate1 = calendar1.get(Calendar.MONTH);
    int yearOfDate1 = calendar1.get(Calendar.YEAR);
    Calendar calendar2 = buildCalendar(date2);
    int monthOfDate2 = calendar2.get(Calendar.MONTH);
    int yearOfDate2 = calendar2.get(Calendar.YEAR);
    int subMonth = Math.abs(monthOfDate1 - monthOfDate2);
    int subYear = Math.abs(yearOfDate1 - yearOfDate2);
    return subYear * 12 + subMonth;
  }
731997
public static function of(int $year) : Year
    {
        Field\Year::check($year);

        return new Year($year);
    }
1137063
public function setStartDate(int $day, int $month, int $year): self
    {
        $this->startDate = [$day, $month, $year];

        return $this;
    }
1075619
public function setDate($year, $month, $day)
    {
        list($year, $month, $day) = self::getGregorian($year, $month, $day);

        return parent::setDate($year, $month, $day);
    }
1096095
public function addYears($years)
    {
        $years = (int) $years;
        $interval = new DateInterval('P' . abs($years) . 'Y');

        if ($years < 0) {
            $interval->invert = 1;
        }

        return $this->add($interval);
    }
681358
public static function diffMonths(\DateTime $dateTime1, \DateTime $dateTime2): int
    {
        $diff = $dateTime1->diff($dateTime2);

        return ((int)$diff->format('%y') * 12) + (int)$diff->format('%m');
    }
880058
public static int getNumOfMonths(Date date1, Date date2) {
		Calendar firstDate = Calendar.getInstance();
		Date date = new Date(date1.getTime());
		firstDate.setTime(date);
		Calendar secondDate = Calendar.getInstance();
		Date date3 = new Date(date2.getTime());
		secondDate.setTime(date3);
		int months = firstDate.get(Calendar.MONTH) - secondDate.get(Calendar.MONTH);

		return months;
	}
1060435
public function twiceMonthly($first = 1, $second = 16)
    {
        $days = $first.','.$second;

        return $this->spliceIntoPosition(1, 0)
            ->spliceIntoPosition(2, 0)
            ->spliceIntoPosition(3, $days);
    }
1189204
public static function getDaysInMonth($month, $year)
    {
        if ($year == 1582 && $month == 10) {
            return 21;  // October 1582 only had 1st-4th and 15th-31st
        }

        if ($month == 2) {
            if (self::isLeapYear($year)) {
                return 29;
            } else {
                return 28;
            }
        } elseif ($month == 4 or $month == 6 or $month == 9 or $month == 11) {
            return 30;
        } else {
            return 31;
        }
    }
761240
public static function ofYearDay(int $year, int $dayOfYear) : LocalDate
    {
        Field\Year::check($year);
        Field\DayOfYear::check($dayOfYear, $year);

        $isLeap = Field\Year::isLeap($year);

        $monthOfYear = Month::of(\intdiv($dayOfYear - 1, 31) + 1);
        $monthEnd = $monthOfYear->getFirstDayOfYear($isLeap) + $monthOfYear->getLength($isLeap) - 1;

        if ($dayOfYear > $monthEnd) {
            $monthOfYear = $monthOfYear->plus(1);
        }

        $dayOfMonth = $dayOfYear - $monthOfYear->getFirstDayOfYear($isLeap) + 1;

        return LocalDate::of($year, $monthOfYear->getValue(), $dayOfMonth);
    }
969563
public function getYear($yearOrStart)
    {
        if (!$yearOrStart instanceof \DateTime) {
            $yearOrStart = new \DateTime(sprintf('%s-01-01', $yearOrStart));
        }

        return $this->getFactory()->createYear($yearOrStart);
    }