* recreate date functions from javascript in new class DateTime
 * move date and time functions from Util to new class
 * fixes various cooldown messages for account recovery
This commit is contained in:
Sarjuuk
2025-11-14 17:00:18 +01:00
parent 1fe3690244
commit f5654ae21f
36 changed files with 409 additions and 188 deletions

View File

@@ -19,7 +19,7 @@ trait TrRecoveryHelper
// check if already processing
if ($_ = DB::Aowow()->selectCell('SELECT `statusTimer` - UNIX_TIMESTAMP() FROM ?_account WHERE `email` = ? AND `status` > ?d AND `statusTimer` > UNIX_TIMESTAMP()', $email, ACC_STATUS_NEW))
return Lang::account('inputbox', 'error', 'isRecovering', [Util::formatTime($_ * 1000)]);
return Lang::account('inputbox', 'error', 'isRecovering', [DateTime::formatTimeElapsed($_ * 1000)]);
// create new token and write to db
$token = Util::createHash();

View File

@@ -228,9 +228,9 @@ class TemplateResponse extends BaseResponse
{
if (User::isInGroup(U_GROUP_EMPLOYEE))
{
$stats['time'] = Util::formatTime((microtime(true) - self::$time) * 1000, true);
$stats['sql'] = ['count' => parent::$sql['count'], 'time' => Util::formatTime(parent::$sql['time'] * 1000, true)];
$stats['cache'] = !empty(static::$cacheStats) ? [static::$cacheStats[0], Util::formatTimeDiff(static::$cacheStats[1])] : null;
$stats['time'] = DateTime::formatTimeElapsed((microtime(true) - self::$time) * 1000);
$stats['sql'] = ['count' => parent::$sql['count'], 'time' => DateTime::formatTimeElapsed(parent::$sql['time'] * 1000)];
$stats['cache'] = !empty(static::$cacheStats) ? [static::$cacheStats[0], (new DateTime())->formatDate(static::$cacheStats[1])] : null;
}
else
$stats = [];

View File

@@ -149,14 +149,14 @@ class TextResponse extends BaseResponse
$this->sumSQLStats();
echo "/*\n";
echo " * generated in ".Util::formatTime((microtime(true) - self::$time) * 1000)."\n";
echo " * " . parent::$sql['count'] . " SQL queries in " . Util::formatTime(parent::$sql['time'] * 1000) . "\n";
echo " * generated in ".DateTime::formatTimeElapsedFloat((microtime(true) - self::$time) * 1000)."\n";
echo " * " . parent::$sql['count'] . " SQL queries in " . DateTime::formatTimeElapsedFloat(parent::$sql['time'] * 1000) . "\n";
if ($this instanceof ICache && static::$cacheStats)
{
[$mode, $set, $lifetime] = static::$cacheStats;
echo " * stored in " . ($mode == CACHE_MODE_MEMCACHED ? 'Memcached' : 'filecache') . ":\n";
echo " * + ".date('c', $set) . ' - ' . Util::formatTimeDiff($set) . "\n";
echo " * - ".date('c', $set + $lifetime) . ' - in '.Util::formatTime(($set + $lifetime - time()) * 1000) . "\n";
echo " * + ".date('c', $set) . ' - ' . DateTime::formatTimeElapsedFloat((time() - $set) * 1000) . " ago\n";
echo " * - ".date('c', $set + $lifetime) . ' - in '.DateTime::formatTimeElapsedFloat(($set + $lifetime - time()) * 1000) . "\n";
}
echo " */\n\n";
}