diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 5718dfac..3790ae64 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -321,6 +321,11 @@ class User extends RowModel { return $this->getRecord()->birthday; } + + function getAge(): ?int + { + return (int)floor((time() - $this->getBirthday()) / mktime(0, 0, 0, 1, 1, 1971)); + } function updateNotificationOffset(): void { diff --git a/Web/Presenters/templates/User/View.xml b/Web/Presenters/templates/User/View.xml index 4440bfe2..58cdaa1d 100644 --- a/Web/Presenters/templates/User/View.xml +++ b/Web/Presenters/templates/User/View.xml @@ -402,8 +402,7 @@ {_"birth_date"}: {date('d F Y',$user->getBirthday())}, - {date('m d') >= date('m d', $user->getBirthday()) ? date('Y') - date('Y', $user->getBirthday()) : - (date('m d') < date('m d', $user->getBirthday()) ? date('Y') - date('Y', $user->getBirthday()) - 1)} {_"years"} + {tr("years", $user->getAge())} {/if} diff --git a/locales/en.strings b/locales/en.strings index 0d85e7e0..1e21c9ba 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -39,7 +39,9 @@ "was_online_m" = "was online"; /* For male and female */ -"years" = "y.o"; +"years_zero" = "0 year old"; +"years_one" = "1 year old"; +"years_other" = "$1 years old"; "was_online_f" = "was online"; "all_title" = "All"; diff --git a/locales/ru.strings b/locales/ru.strings index 7e175268..16ceebb8 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -45,9 +45,14 @@ "no_information_provided" = "Информация отсутствует."; "deceased_person" = "Страница покойного человека"; "none" = "отсутствует"; -"years" = "лет"; "send" = "Отправить"; +"years_zero" = "0 лет"; +"years_one" = "1 год"; +"years_few" = "$1 года фю"; +"years_many" = "$1 лет мани"; +"years_other" = "$1 лет"; + "relationship" = "Семейное положение"; "relationship_0" = "Не выбрано";