. */ namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Individual; /** * The month of marriage, if within the last year. */ class CensusColumnMonthIfMarriedWithinYear extends AbstractCensusColumn implements CensusColumnInterface { /** * Generate the likely value of this census column, based on available information. * * @param Individual $individual * * @return string */ public function generate(Individual $individual) { foreach ($individual->getSpouseFamilies() as $family) { foreach ($family->getFacts('MARR') as $fact) { if ($fact->getDate()->julianDay() + 365 >= $this->date()->julianDay()) { // Use the GEDCOM month, as we need this in English - for the US census return ucfirst(strtolower($fact->getDate()->minimumDate()->format('%O'))); } } } return ''; } }