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

@param int $year1
@param int $year2

@return Builder
974457
public function monthFirstChildBySexQuery(int $year1 = -1, int $year2 = -1): Builder
    {
        return $this->monthFirstChildQuery($year1, $year2)
                ->join('individuals', static function (JoinClause $join): void {
                    $join
                        ->on('i_file', '=', 'l_file')
                        ->on('i_id', '=', 'l_to');
                })
                ->select(['d_month', 'i_sex', DB::raw('COUNT(*) AS total')])
                ->groupBy(['d_month', 'i_sex']);
    }
19927
public static function year($year = null)
	{
		$from = DateTime::create(1, 1, $year);
		$till = $from->copy()->addYears(1)->addDays(-1);
		return new Calendar($from, $till);
	}
132137
public function statsFirstMarriageQuery(int $year1 = -1, int $year2 = -1): Builder
    {
        $query = DB::table('families')
            ->join('dates', static function (JoinClause $join): void {
                $join
                    ->on('d_gid', '=', 'f_id')
                    ->on('d_file', '=', 'f_file')
                    ->where('d_fact', '=', 'MARR')
                    ->whereIn('d_month', ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'])
                    ->where('d_julianday2', '<>', 0);
            })->join('individuals', static function (JoinClause $join): void {
                $join
                    ->on('i_file', '=', 'f_file');
            })
            ->where('f_file', '=', $this->tree->id())
            ->where(static function (Builder $query): void {
                $query
                    ->whereColumn('i_id', '=', 'f_husb')
                    ->orWhereColumn('i_id', '=', 'f_wife');
            });

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

        return $query
            ->select(['f_id AS fams', 'f_husb', 'f_wife', 'd_julianday2 AS age', 'd_month AS month', 'i_id AS indi'])
            ->orderBy('f_id')
            ->orderBy('i_id')
            ->orderBy('d_julianday2');
    }
1314760
private function getDaysInMonth(Month $month, Year $year)
    {
        return (int)date('t', mktime(0, 0, 0, (string)$month, 1, (string)$year));
    }
22479
public function getMonth($year, $monthNo)
    {
        $year = $this->yearOrYearNo($year);

        return new Month($year, $monthNo);
    }
441969
public function statsMarriageQuery(int $year1 = -1, int $year2 = -1): Builder
    {
        $query = DB::table('dates')
            ->where('d_file', '=', $this->tree->id())
            ->where('d_fact', '=', 'MARR')
            ->select(['d_month', DB::raw('COUNT(*) AS total')])
            ->groupBy('d_month');

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

        return $query;
    }
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);
    }
1191479
public function compareTo(YearMonth $that) : int
    {
        if ($this->year < $that->year) {
            return -1;
        }
        if ($this->year > $that->year) {
            return 1;
        }
        if ($this->month < $that->month) {
            return -1;
        }
        if ($this->month > $that->month) {
            return 1;
        }

        return 0;
    }
265766
public function firstAirDateYear($year)
    {
        if ($year instanceof \DateTime) {
            $year = $year->format('Y');
        }

        $this->set('first_air_date_year', (int) $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);
    }
69608
public function getHour($yearOrStart, $month = null, $day = null, $hour = null)
    {
        if (!$yearOrStart instanceof \DateTime) {
            $yearOrStart = new \DateTime(sprintf('%s-%s-%s %s:00', $yearOrStart, $month, $day, $hour));
        }

        return $this->getFactory()->createHour($yearOrStart);
    }
972226
public function statsDeathBySexQuery(int $year1 = -1, int $year2 = -1): Builder
    {
        return $this->statsDeathQuery($year1, $year2)
                ->select(['d_month', 'i_sex', DB::raw('COUNT(*) AS total')])
                ->join('individuals', static function (JoinClause $join): void {
                    $join
                        ->on('i_id', '=', 'd_gid')
                        ->on('i_file', '=', 'd_file');
                })
                ->groupBy('i_sex');
    }
506490
public static CalendarPeriod<CalendarYear> between(
        CalendarYear y1,
        CalendarYear y2
    ) {

        return new FixedCalendarPeriod<>(y1, y2, FixedCalendarTimeLine.forYears());

    }
314341
public function setDate($year, $month, $day)
    {
        if (self::$_immutable) {
            self::$_immutable = false;
            $newDate = clone $this;
            $newDate->setDate($year, $month, $day);
            self::$_immutable = true;

            return $newDate;
        } else {
            return parent::setDate($year, $month, $day);
        }
    }
1172063
protected function yearOrYearNo($year)
    {
        if (is_scalar($year)) {
            return $this->getYear($year);
        }

        if (!$year instanceof Year) {
            throw new InvalidArgumentException(
                '$year must be an instance of BmCalendar\Year; got "' . get_class($year) . '"'
            );
        }

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

        return $this;
    }
201161
public static function firstDayOfMonth($month = null, $year = null, $format = 'Y-m-d')
    {
        $year = $year ? $year : date('Y');
        $month = $month ? $month : date('m');
        return date($format, mktime(0, 0, 0, $month, 1, $year));
    }