xref: /webtrees/app/Census/CensusColumnBirthDayMonthYear.php (revision 28ae205ea489debfa3ff7190c52711479d6a6348)
1*28ae205eSDavid Drury<?php
2*28ae205eSDavid Drury
3*28ae205eSDavid Drury/**
4*28ae205eSDavid Drury * webtrees: online genealogy
5*28ae205eSDavid Drury * Copyright (C) 2019 webtrees development team
6*28ae205eSDavid Drury * This program is free software: you can redistribute it and/or modify
7*28ae205eSDavid Drury * it under the terms of the GNU General Public License as published by
8*28ae205eSDavid Drury * the Free Software Foundation, either version 3 of the License, or
9*28ae205eSDavid Drury * (at your option) any later version.
10*28ae205eSDavid Drury * This program is distributed in the hope that it will be useful,
11*28ae205eSDavid Drury * but WITHOUT ANY WARRANTY; without even the implied warranty of
12*28ae205eSDavid Drury * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13*28ae205eSDavid Drury * GNU General Public License for more details.
14*28ae205eSDavid Drury * You should have received a copy of the GNU General Public License
15*28ae205eSDavid Drury * along with this program. If not, see <http://www.gnu.org/licenses/>.
16*28ae205eSDavid Drury */
17*28ae205eSDavid Drury
18*28ae205eSDavid Drurydeclare(strict_types=1);
19*28ae205eSDavid Drury
20*28ae205eSDavid Drurynamespace Fisharebest\Webtrees\Census;
21*28ae205eSDavid Drury
22*28ae205eSDavid Druryuse Fisharebest\Webtrees\Individual;
23*28ae205eSDavid Drury
24*28ae205eSDavid Drury/**
25*28ae205eSDavid Drury * The individual's date of birth.
26*28ae205eSDavid Drury */
27*28ae205eSDavid Druryclass CensusColumnBirthDayMonthYear extends AbstractCensusColumn implements CensusColumnInterface
28*28ae205eSDavid Drury{
29*28ae205eSDavid Drury    /**
30*28ae205eSDavid Drury     * Generate the likely value of this census column, based on available information.
31*28ae205eSDavid Drury     *
32*28ae205eSDavid Drury     * @param Individual $individual
33*28ae205eSDavid Drury     * @param Individual $head
34*28ae205eSDavid Drury     *
35*28ae205eSDavid Drury     * @return string
36*28ae205eSDavid Drury     */
37*28ae205eSDavid Drury    public function generate(Individual $individual, Individual $head): string
38*28ae205eSDavid Drury    {
39*28ae205eSDavid Drury        $birth_date = $individual->getBirthDate();
40*28ae205eSDavid Drury
41*28ae205eSDavid Drury        if ($birth_date->minimumJulianDay() === $birth_date->maximumJulianDay()) {
42*28ae205eSDavid Drury            return $birth_date->minimumDate()->format('%d %M %Y');
43*28ae205eSDavid Drury        }
44*28ae205eSDavid Drury
45*28ae205eSDavid Drury        return '';
46*28ae205eSDavid Drury    }
47*28ae205eSDavid Drury}
48