Add support for user defined locale and timezone in date/time prints, remove deprecated PHP strftime

This commit is contained in:
leosw
2022-02-01 21:13:27 +01:00
parent 3a497bbb64
commit 7ec61dbc63
7 changed files with 26 additions and 14 deletions

View File

@@ -6,17 +6,29 @@ ini_set("session.cookie_lifetime",60*60*24*30);
session_start();
$user = new Kabano\User();
$user->rank = "visitor"; // All users are visitors
if(isset($_SESSION['userid'])) {
$user->checkID($_SESSION['userid']);
if ($user->checkID($_SESSION['userid'])) {
$user->updateLoginDate();
//setlocale(LC_ALL, $config['locales'][$user->locale][4]);
$config['locale'] = $user->locale;
$config['timezone'] = $user->timezone;
}
else {
session_destroy();
$config['locale'] = locale_get_default();
$config['timezone'] = date_default_timezone_get();
$user->rank = "visitor"; // All users are visitors
}
}
else {
$config['locale'] = locale_get_default();
$config['timezone'] = date_default_timezone_get();
$user->rank = "visitor"; // All users are visitors
}
$user->date_format = new IntlDateFormatter($config['locale'], IntlDateFormatter::LONG, IntlDateFormatter::NONE, $config['timezone']);
$user->datetime_format = new IntlDateFormatter($config['locale'], IntlDateFormatter::LONG, IntlDateFormatter::SHORT, $config['timezone']);
$user->datetimeshort_format = new IntlDateFormatter($config['locale'], IntlDateFormatter::SHORT, IntlDateFormatter::SHORT, $config['timezone']);
?>