mirror of
https://github.com/humhub/humhub.git
synced 2025-01-16 21:58:17 +01:00
Fix birthday with hidden year in a language-specific format (#5205)
* Fix birthday with hidden year in a language-specific format * Update Birthday.php Co-authored-by: Lucas Bartholemy <luke-@users.noreply.github.com>
This commit is contained in:
parent
bda35f5f4b
commit
2623fdad69
@ -8,6 +8,7 @@ HumHub Changelog
|
||||
- Fix #5172: Missing translations for "New Member" and "New Spaces" directory widgets
|
||||
- Fix #5195: Fix export users with tags data
|
||||
- Fix #5200: Auto creating following for friends
|
||||
- Fix #5187: Fix birthday with hidden year in a language-specific format
|
||||
- Enh #5189: Reduce minimum character limit for tags to 2 chars
|
||||
|
||||
|
||||
|
@ -199,11 +199,22 @@ class Birthday extends BaseType
|
||||
}
|
||||
}
|
||||
|
||||
$longDate = Yii::$app->formatter->asDate($birthdayDate, 'long');
|
||||
|
||||
/*
|
||||
* - user set hide age yes
|
||||
*/
|
||||
if ($hideAge === self::HIDE_AGE_YES) {
|
||||
return Yii::$app->formatter->asDate($birthdayDate, 'dd. MMMM');
|
||||
// See: https://github.com/humhub/humhub/issues/5187#issuecomment-888178022
|
||||
|
||||
$month = Yii::$app->formatter->asDate($birthdayDate, 'php:F');
|
||||
$day = Yii::$app->formatter->asDate($birthdayDate, 'php:d');
|
||||
if (preg_match('/(' . preg_quote($day) . '.+' . preg_quote($month) . '|' . preg_quote($month) . '.+' . preg_quote($day) . ')/', $longDate, $m)) {
|
||||
return $m[0];
|
||||
}
|
||||
|
||||
$year = Yii::$app->formatter->asDate($birthdayDate, 'php:Y');
|
||||
return preg_replace('/[,\s]*' . preg_quote($year) . '([^\d]+|$)/', '', $longDate);
|
||||
}
|
||||
|
||||
$ageInYears = Yii::t(
|
||||
@ -212,7 +223,7 @@ class Birthday extends BaseType
|
||||
['%y' => $birthdayDate->diff(new \DateTime())->y]
|
||||
);
|
||||
|
||||
return Yii::$app->formatter->asDate($birthdayDate, 'long') . ' (' . $ageInYears . ')';
|
||||
return $longDate . ' (' . $ageInYears . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user