Returns the calculated age the time of event.

@param int $age The age from the database record

@return string
563
private function calculateAge(int $age): string
    {
        if ((int) ($age / 365.25) > 0) {
            $result = (int) ($age / 365.25) . 'y';
        } elseif ((int) ($age / 30.4375) > 0) {
            $result = (int) ($age / 30.4375) . 'm';
        } else {
            $result = $age . 'd';
        }

        return FunctionsDate::getAgeAtEvent($result);
    }
1034369
def age(self):
        
        
        # Created timestamp
        created = self.created()
        
        # Age in seconds / minutes / hours / days
        age_secs  = time() - created
        age_mins  = 0 if (age_secs < 60) else (age_secs / 60)
        age_hours = 0 if (age_secs < 3600) else (age_mins / 60)
        age_days  = 0 if (age_secs < 86400) else (age_hours / 24)
        
        # Return the age tuple
        return (
            int(age_secs), 
            int(age_mins), 
            int(age_hours), 
            int(age_days)
        )
855339
public function age($value)
    {
        if (!isset($value)) {
            return null;
        }
        
        $date = $this->valueToDateTime($value);
        
        return $date->diff(new \DateTime())->format('%y');
    }
418369
private function getExpiresTime($time): int
    {
        if ($time instanceof \DateTimeInterface) {
            return (int) $time->format('U');
        }

        if (\is_numeric($time)) {
            // average year in seconds
            if ($time <= 31557600) {
                $time += \time();
            }

            return (int) $time;
        }

        return (int) (new \DateTime($time))->format('U');
    }
594700
public static function YearsFromDuration( $arg )
	{
		if ( $arg instanceof Undefined )
		    return Undefined::getValue();

		/**
		 * @var DurationValue $duration
		 */
		$duration = $arg;
		return Integer::FromValue( $duration->getYears() * ( $duration->getInverted() ? -1 : 1 ) );
	}
620303
protected function getExpiryTime( $id )
    {
        $storedTimeStamp = $this->expiryHandler->hasTimestamp( $id ) ? $this->expiryHandler->timestamp( $id ) : false;
        $expiryTime = $storedTimeStamp !== false ? $storedTimeStamp : 0;

        return $expiryTime;
    }
212221
def age(self, as_at_date=None):
        
        if self.date_of_death != None or self.is_deceased == True:
            return None

        as_at_date = date.today() if as_at_date == None else as_at_date
        
        if self.date_of_birth != None:
            if (as_at_date.month >= self.date_of_birth.month) and (as_at_date.day >= self.date_of_birth.day):
                return (as_at_date.year - self.date_of_birth.year)
            else:
                return ((as_at_date.year - self.date_of_birth.year) -1)
        else:
            return None
230529
protected function extractYear(string $year): int
    {
        if (preg_match('/^(\d\d\d\d)\/\d{1,4}$/', $year, $match)) {
            // Assume the first year is correct
            $this->new_old_style = true;

            return (int) $match[1] + 1;
        }

        if (preg_match('/^(\d+) B\.C\.$/', $year, $match)) {
            return - (int) $match[1];
        }

        return (int) $year;
    }
581196
private function ageBetweenSiblingsNoList(int $total): array
    {
        $rows = $this->ageBetweenSiblingsQuery($total);

        foreach ($rows as $fam) {
            $family = Family::getInstance($fam->family, $this->tree);
            $child1 = Individual::getInstance($fam->ch1, $this->tree);
            $child2 = Individual::getInstance($fam->ch2, $this->tree);

            if ($child1->canShow() && $child2->canShow()) {
                // ! Single array (no list)
                return [
                    'child1' => $child1,
                    'child2' => $child2,
                    'family' => $family,
                    'age'    => $this->calculateAge((int) $fam->age),
                ];
            }
        }

        return [];
    }
321001
public function getControledLifetime($lifetime)
    {
        if (
            null !== $this->_instance_options['min_lifetime']
            && $this->_instance_options['min_lifetime'] > $lifetime
        ) {
            $lifetime = $this->_instance_options['min_lifetime'];
        } elseif (
            null !== $this->_instance_options['max_lifetime']
            && $this->_instance_options['max_lifetime'] < $lifetime
        ) {
            $lifetime = $this->_instance_options['max_lifetime'];
        }

        return $lifetime;
    }
924186
@Nullable
	public Age getAge(int tag)
    {
        final String ageString = getString(tag);
        if (ageString==null)
            return null;
        return Age.fromPanasonicString(ageString);
	}
176044
public static function getAgeAtEvent(string $age_string): string
    {
        switch (strtoupper($age_string)) {
            case 'CHILD':
                return I18N::translate('Child');
            case 'INFANT':
                return I18N::translate('Infant');
            case 'STILLBORN':
                return I18N::translate('Stillborn');
            default:
                return preg_replace_callback(
                    [
                        '/(\d+)([ymwd])/',
                    ],
                    static function (array $match): string {
                        $num = (int) $match[1];

                        switch ($match[2]) {
                            case 'y':
                                return I18N::plural('%s year', '%s years', $num, I18N::number($num));
                            case 'm':
                                return I18N::plural('%s month', '%s months', $num, I18N::number($num));
                            case 'w':
                                return I18N::plural('%s week', '%s weeks', $num, I18N::number($num));
                            case 'd':
                                return I18N::plural('%s day', '%s days', $num, I18N::number($num));
                            default:
                                throw new LogicException('Should never get here');
                        }
                    },
                    $age_string
                );
        }
    }
799567
def age_to_date(age):
    
    today = datetime.date.today()
    date = datetime.date(today.year - age - 1, today.month, today.day) + datetime.timedelta(days=1)
    return date
502490
public function getTime() {
		$eventTime = $this->getTimeStamp();
		$eventStartTime = LoggingEvent::getStartTime();
		return number_format(($eventTime - $eventStartTime) * 1000, 0, '', '');
	}
1222122
private function getLastDate()
    {
        /* get the last date with calculated snapshots */
        $req = new AGetLastDateRequest();
        /** @var  AGetLastDateResponse $resp */
        $resp = $this->servGetLastDate->exec($req);
        $result = $resp->getLastDate();
        return $result;
    }
891003
public function age()
    {
        if ($this->wrappedObject->birthdate == null) {
            return;
        }

        $reference = new \DateTime();
        $born = new \DateTime($this->wrappedObject->birthdate);

        if ($this->wrappedObject->birthdate > $reference) {
            throw new InvalidContactAgeException;
        }

        $diff = $reference->diff($born);

        return $diff->y;
    }
982208
public function ageBetweenSpousesMF(int $total = 10): string
    {
        $records = $this->ageBetweenSpousesQuery('DESC', $total);

        return view('statistics/families/top10-nolist-spouses', [
            'records' => $records,
        ]);
    }