. */ namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Individual; /** * The month of birth, if within the last year. */ class CensusColumnMonthIfBornWithinYear extends AbstractCensusColumn implements CensusColumnInterface { /** * Generate the likely value of this census column, based on available information. * * @param Individual $individual * @param Individual $head * * @return string */ public function generate(Individual $individual, Individual $head): string { $birth_jd = $individual->getBirthDate()->julianDay(); $census_jd = $this->date()->julianDay(); if ($birth_jd <= $census_jd && $birth_jd >= $census_jd - 365) { // Use the GEDCOM month, as we need this in English - for the US census return ucfirst(strtolower($individual->getBirthDate()->minimumDate()->format('%O'))); } return ''; } }