User: Age refactoring

Лапский, это вообще пиздец какой-то. Проще не додумался сделать?
This commit is contained in:
veselcraft 2021-11-27 21:02:37 +03:00
parent f3791f6478
commit fd2ef5fad5
No known key found for this signature in database
GPG key ID: AED66BC1AC628A4E
4 changed files with 15 additions and 4 deletions

View file

@ -322,6 +322,11 @@ class User extends RowModel
return $this->getRecord()->birthday; return $this->getRecord()->birthday;
} }
function getAge(): ?int
{
return (int)floor((time() - $this->getBirthday()) / mktime(0, 0, 0, 1, 1, 1971));
}
function updateNotificationOffset(): void function updateNotificationOffset(): void
{ {
$this->stateChanges("notification_offset", time()); $this->stateChanges("notification_offset", time());

View file

@ -402,8 +402,7 @@
<tr> <tr>
<td class="label"><span class="nobold">{_"birth_date"}:</span></td> <td class="label"><span class="nobold">{_"birth_date"}:</span></td>
<td class="data">{date('d F Y',$user->getBirthday())}, <td class="data">{date('d F Y',$user->getBirthday())},
{date('m d') >= date('m d', $user->getBirthday()) ? date('Y') - date('Y', $user->getBirthday()) : {tr("years", $user->getAge())}</td>
(date('m d') < date('m d', $user->getBirthday()) ? date('Y') - date('Y', $user->getBirthday()) - 1)} {_"years"}</td>
</tr> </tr>
{/if} {/if}
</tbody> </tbody>

View file

@ -39,7 +39,9 @@
"was_online_m" = "was online"; "was_online_m" = "was online";
/* For male and female */ /* 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"; "was_online_f" = "was online";
"all_title" = "All"; "all_title" = "All";

View file

@ -45,9 +45,14 @@
"no_information_provided" = "Информация отсутствует."; "no_information_provided" = "Информация отсутствует.";
"deceased_person" = "Страница покойного человека"; "deceased_person" = "Страница покойного человека";
"none" = "отсутствует"; "none" = "отсутствует";
"years" = "лет";
"send" = "Отправить"; "send" = "Отправить";
"years_zero" = "0 лет";
"years_one" = "1 год";
"years_few" = "$1 года фю";
"years_many" = "$1 лет мани";
"years_other" = "$1 лет";
"relationship" = "Семейное положение"; "relationship" = "Семейное положение";
"relationship_0" = "Не выбрано"; "relationship_0" = "Не выбрано";