mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
DateTime
* 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:
@@ -112,7 +112,7 @@ class AccountBaseResponse extends TemplateResponse
|
||||
|
||||
// Username
|
||||
$this->curName = User::$username;
|
||||
$this->renameCD = Util::formatTime(Cfg::get('ACC_RENAME_DECAY') * 1000);
|
||||
$this->renameCD = DateTime::formatTimeElapsedFloat(Cfg::get('ACC_RENAME_DECAY') * 1000);
|
||||
if ($user['renameCooldown'] > time())
|
||||
{
|
||||
$locCode = implode('_', str_split(Lang::getLocale()->json(), 2)); // ._.
|
||||
|
||||
@@ -76,7 +76,7 @@ class AccountforgotpasswordResponse extends TemplateResponse
|
||||
|
||||
// on cooldown pretend we dont know the email address
|
||||
if ($timeout && $timeout > time())
|
||||
return Cfg::get('DEBUG') ? 'resend on cooldown: '.Util::formatTimeDiff($timeout).' remaining' : Lang::account('inputbox', 'error', 'emailNotFound');
|
||||
return Cfg::get('DEBUG') ? 'resend on cooldown: '.DateTime::formatTimeElapsed($timeout * 1000).' remaining' : Lang::account('inputbox', 'error', 'emailNotFound');
|
||||
|
||||
// pretend recovery started
|
||||
if (!DB::Aowow()->selectCell('SELECT 1 FROM ?_account WHERE `email` = ?', $this->_post['email']))
|
||||
|
||||
@@ -75,7 +75,7 @@ class AccountforgotusernameResponse extends TemplateResponse
|
||||
|
||||
// on cooldown pretend we dont know the email address
|
||||
if ($timeout && $timeout > time())
|
||||
return Cfg::get('DEBUG') ? 'resend on cooldown: '.Util::formatTimeDiff($timeout).' remaining' : Lang::account('inputbox', 'error', 'emailNotFound');
|
||||
return Cfg::get('DEBUG') ? 'resend on cooldown: '.DateTime::formatTimeElapsed($timeout * 1000).' remaining' : Lang::account('inputbox', 'error', 'emailNotFound');
|
||||
|
||||
// pretend recovery started
|
||||
if (!DB::Aowow()->selectCell('SELECT 1 FROM ?_account WHERE `email` = ?', $this->_post['email']))
|
||||
|
||||
@@ -73,7 +73,7 @@ class AccountResendResponse extends TemplateResponse
|
||||
|
||||
// on cooldown pretend we dont know the email address
|
||||
if ($timeout && $timeout > time())
|
||||
return Cfg::get('DEBUG') ? 'resend on cooldown: '.Util::formatTimeDiff($timeout).' remaining' : Lang::account('inputbox', 'error', 'emailNotFound');
|
||||
return Cfg::get('DEBUG') ? 'resend on cooldown: '.DateTime::formatTimeElapsed($timeout * 1000).' remaining' : Lang::account('inputbox', 'error', 'emailNotFound');
|
||||
|
||||
// check email and account status
|
||||
if ($token = DB::Aowow()->selectCell('SELECT `token` FROM ?_account WHERE `email` = ? AND `status` = ?d', $this->_post['email'], ACC_STATUS_NEW))
|
||||
|
||||
@@ -99,7 +99,7 @@ class AccountSigninResponse extends TemplateResponse
|
||||
// AUTH_BANNED => Lang::account('accBanned'); // ToDo: should this return an error? the actual account functionality should be blocked elsewhere
|
||||
AUTH_WRONGUSER => Lang::account('userNotFound'),
|
||||
AUTH_WRONGPASS => Lang::account('wrongPass'),
|
||||
AUTH_IPBANNED => Lang::account('inputbox', 'error', 'loginExceeded', [Util::formatTime(Cfg::get('ACC_FAILED_AUTH_BLOCK') * 1000)]),
|
||||
AUTH_IPBANNED => Lang::account('inputbox', 'error', 'loginExceeded', [DateTime::formatTimeElapsedFloat(Cfg::get('ACC_FAILED_AUTH_BLOCK') * 1000)]),
|
||||
AUTH_INTERNAL_ERR => Lang::main('intError'),
|
||||
default => Lang::main('intError')
|
||||
};
|
||||
|
||||
@@ -112,7 +112,7 @@ class AccountSignupResponse extends TemplateResponse
|
||||
if (DB::Aowow()->selectRow('SELECT 1 FROM ?_account_bannedips WHERE `type` = ?d AND `ip` = ? AND `count` >= ?d AND `unbanDate` >= UNIX_TIMESTAMP()', IP_BAN_TYPE_REGISTRATION_ATTEMPT, User::$ip, Cfg::get('ACC_FAILED_AUTH_COUNT')))
|
||||
{
|
||||
DB::Aowow()->query('UPDATE ?_account_bannedips SET `count` = `count` + 1, `unbanDate` = UNIX_TIMESTAMP() + ?d WHERE `ip` = ? AND `type` = ?d', Cfg::get('ACC_FAILED_AUTH_BLOCK'), User::$ip, IP_BAN_TYPE_REGISTRATION_ATTEMPT);
|
||||
return Lang::account('inputbox', 'error', 'signupExceeded', [Util::formatTime(Cfg::get('ACC_FAILED_AUTH_BLOCK') * 1000)]);
|
||||
return Lang::account('inputbox', 'error', 'signupExceeded', [DateTime::formatTimeElapsedFloat(Cfg::get('ACC_FAILED_AUTH_BLOCK') * 1000)]);
|
||||
}
|
||||
|
||||
// username / email taken
|
||||
|
||||
@@ -53,7 +53,7 @@ class AccountUpdateemailResponse extends TextResponse
|
||||
|
||||
$status = DB::Aowow()->selectCell('SELECT `status` FROM ?_account WHERE `statusTimer` > UNIX_TIMESTAMP() AND `id` = ?d', User::$id);
|
||||
if ($status != ACC_STATUS_NONE && $status != ACC_STATUS_CHANGE_EMAIL)
|
||||
return Lang::account('isRecovering', [Util::formatTime(Cfg::get('ACC_RECOVERY_DECAY') * 1000)]);
|
||||
return Lang::account('inputbox', 'error', 'isRecovering', [DateTime::formatTimeElapsedFloat(Cfg::get('ACC_RECOVERY_DECAY') * 1000)]);
|
||||
|
||||
$oldEmail = DB::Aowow()->selectCell('SELECT `email` FROM ?_account WHERE `id` = ?d', User::$id);
|
||||
if ($this->_post['newemail'] == $oldEmail)
|
||||
|
||||
@@ -55,7 +55,7 @@ class AccountUpdatepasswordResponse extends TextResponse
|
||||
|
||||
$userData = DB::Aowow()->selectRow('SELECT `status`, `passHash`, `statusTimer` FROM ?_account WHERE `id` = ?d', User::$id);
|
||||
if ($userData['status'] != ACC_STATUS_NONE && $userData['status'] != ACC_STATUS_CHANGE_PASS && $userData['statusTimer'] > time())
|
||||
return Lang::account('isRecovering', [Util::formatTime(Cfg::get('ACC_RECOVERY_DECAY') * 1000)]);
|
||||
return Lang::account('inputbox', 'error', 'isRecovering', [DateTime::formatTimeElapsedFloat(Cfg::get('ACC_RECOVERY_DECAY') * 1000)]);
|
||||
|
||||
if (!User::verifyCrypt($this->_post['currentPassword'], $userData['passHash']))
|
||||
return Lang::account('wrongPass');
|
||||
|
||||
@@ -327,7 +327,7 @@ class EventBaseResponse extends TemplateResponse implements ICache
|
||||
|
||||
// interval
|
||||
if ($rec > 0)
|
||||
$infobox[] = Lang::event('interval').Util::formatTime($rec * 1000);
|
||||
$infobox[] = Lang::event('interval').DateTime::formatTimeElapsed($rec * 1000);
|
||||
|
||||
// in progress
|
||||
if ($start < time() && $end > time())
|
||||
|
||||
@@ -79,20 +79,21 @@ class GuideChangelogResponse extends TemplateResponse
|
||||
|
||||
$buff = '<ul>';
|
||||
$inp = fn($rev) => User::isInGroup(U_GROUP_STAFF) && false ? ($rev !== null ? '<input name="a" value="'.$rev.'" type="radio"/><input name="b" value="'.$rev.'" type="radio"/><b>' : '<b style="margin-left:38px;">') : '';
|
||||
$now = new DateTime();
|
||||
|
||||
$logEntries = DB::Aowow()->select('SELECT a.`username` AS `name`, gcl.`date`, gcl.`status`, gcl.`msg`, gcl.`rev` FROM ?_guides_changelog gcl JOIN ?_account a ON a.`id` = gcl.`userId` WHERE gcl.`id` = ?d ORDER BY gcl.`date` DESC', $this->_get['id']);
|
||||
foreach ($logEntries as $log)
|
||||
{
|
||||
if ($log['status'] != GuideMgr::STATUS_NONE)
|
||||
$buff .= '<li class="guide-changelog-status-change">'.$inp($log['rev']).'<b>'.Lang::guide('clStatusSet', [Lang::guide('status', $log['status'])]).'</b>'.Util::formatTimeDiff($log['date'])."</li>\n";
|
||||
$buff .= '<li class="guide-changelog-status-change">'.$inp($log['rev']).'<b>'.Lang::guide('clStatusSet', [Lang::guide('status', $log['status'])]).'</b>'.$now->formatDate($log['date'], true)."</li>\n";
|
||||
else if ($log['msg'])
|
||||
$buff .= '<li>'.$inp($log['rev']).'<b>'.Util::formatTimeDiff($log['date']).Lang::main('colon').'</b>'.$log['msg'].' <i class="q0">'.Lang::main('byUser', [$log['name'], 'style="text-decoration:underline"'])."</i></li>\n";
|
||||
$buff .= '<li>'.$inp($log['rev']).'<b>'.$now->formatDate($log['date'], true).Lang::main('colon').'</b>'.$log['msg'].' <i class="q0">'.Lang::main('byUser', [$log['name'], 'style="text-decoration:underline"'])."</i></li>\n";
|
||||
else
|
||||
$buff .= '<li class="guide-changelog-minor-edit">'.$inp($log['rev']).'<b>'.Util::formatTimeDiff($log['date']).Lang::main('colon').'</b><i>'.Lang::guide('clMinorEdit').'</i> <i class="q0">'.Lang::main('byUser', [$log['name'], 'style="text-decoration:underline"'])."</i></li>\n";
|
||||
$buff .= '<li class="guide-changelog-minor-edit">'.$inp($log['rev']).'<b>'.$now->formatDate($log['date'], true).Lang::main('colon').'</b><i>'.Lang::guide('clMinorEdit').'</i> <i class="q0">'.Lang::main('byUser', [$log['name'], 'style="text-decoration:underline"'])."</i></li>\n";
|
||||
}
|
||||
|
||||
// append creation
|
||||
$buff .= '<li class="guide-changelog-created">'.$inp(0).'<b>'.Lang::guide('clCreated').'</b>'.Util::formatTimeDiff($guide->getField('date'))."</li>\n</ul>\n";
|
||||
$buff .= '<li class="guide-changelog-created">'.$inp(0).'<b>'.Lang::guide('clCreated').'</b>'.$now->formatDate($guide->getField('date'), true)."</li>\n</ul>\n";
|
||||
|
||||
if (User::isInGroup(U_GROUP_STAFF) && false)
|
||||
$buff .= '<input type="button" value="Compare" onclick="alert(\'NYI\');" style="margin-left: 40px;"/>';
|
||||
|
||||
@@ -14,6 +14,8 @@ class LatestcommentsRssResponse extends TextResponse
|
||||
|
||||
protected function generate() : void
|
||||
{
|
||||
$now = new DateTime();
|
||||
|
||||
foreach (CommunityContent::getCommentPreviews(['comments' => 1, 'replies' => 1], dateFmt: false) as $comment)
|
||||
{
|
||||
if (empty($comment['commentid']))
|
||||
@@ -25,7 +27,7 @@ class LatestcommentsRssResponse extends TextResponse
|
||||
$this->feedData[] = array(
|
||||
'title' => [true, [], Lang::typeName($comment['type']).Lang::main('colon').htmlentities($comment['subject'])],
|
||||
'link' => [false, [], $url],
|
||||
'description' => [true, [], htmlentities($comment['preview'])."<br /><br />".Lang::main('byUser', [$comment['user'], '']) . Util::formatTimeDiff($comment['date'])],
|
||||
'description' => [true, [], htmlentities($comment['preview'])."<br /><br />".Lang::main('byUser', [$comment['user'], '']) . $now->formatDate($comment['date'], true)],
|
||||
'pubDate' => [false, [], date(DATE_RSS, $comment['date'])],
|
||||
'guid' => [false, [], $url]
|
||||
// 'domain' => [false, [], null]
|
||||
|
||||
@@ -14,12 +14,14 @@ class LatestscreenshotsRssResponse extends TextResponse
|
||||
|
||||
protected function generate() : void
|
||||
{
|
||||
$now = new DateTime();
|
||||
|
||||
foreach (CommunityContent::getScreenshots(dateFmt: false) as $screenshot)
|
||||
{
|
||||
$desc = '<a href="'.Cfg::get('HOST_URL').'/?'.Type::getFileString($screenshot['type']).'='.$screenshot['typeId'].'#screenshots:id='.$screenshot['id'].'"><img src="'.Cfg::get('STATIC_URL').'/uploads/screenshots/thumb/'.$screenshot['id'].'.jpg" alt="" /></a>';
|
||||
if ($screenshot['caption'])
|
||||
$desc .= '<br />'.$screenshot['caption'];
|
||||
$desc .= "<br /><br />".Lang::main('byUser', [$screenshot['user'], '']) . Util::formatTimeDiff($screenshot['date'], true);
|
||||
$desc .= "<br /><br />".Lang::main('byUser', [$screenshot['user'], '']) . $now->formatDate($screenshot['date'], true);
|
||||
|
||||
// enclosure/length => filesize('static/uploads/screenshots/thumb/'.$screenshot['id'].'.jpg') .. always set to this placeholder value though
|
||||
$this->feedData[] = array(
|
||||
|
||||
@@ -14,12 +14,14 @@ class LatestvideosRssResponse extends TextResponse
|
||||
|
||||
protected function generate() : void
|
||||
{
|
||||
$now = new DateTime();
|
||||
|
||||
foreach (CommunityContent::getvideos(dateFmt: false) as $video)
|
||||
{
|
||||
$desc = '<a href="'.Cfg::get('HOST_URL').'/?'.Type::getFileString($video['type']).'='.$video['typeId'].'#videos:id='.$video['id'].'"><img src="//i3.ytimg.com/vi/'.$video['videoId'].'/default.jpg" alt="" /></a>';
|
||||
if ($video['caption'])
|
||||
$desc .= '<br />'.$video['caption'];
|
||||
$desc .= "<br /><br />".Lang::main('byUser', [$video['user'], '']) . Util::formatTimeDiff($video['date'], true);
|
||||
$desc .= "<br /><br />".Lang::main('byUser', [$video['user'], '']) . $now->formatDate($video['date'], true);
|
||||
|
||||
// is enclosure/length .. is this even relevant..?
|
||||
$this->feedData[] = array(
|
||||
|
||||
@@ -99,7 +99,7 @@ class MailBaseResponse extends TemplateResponse implements ICache
|
||||
}
|
||||
|
||||
if ($q['rewardMailDelay'] > 0)
|
||||
$infobox[] = Lang::mail('delay', [Util::formatTime($q['rewardMailDelay'] * 1000)]);
|
||||
$infobox[] = Lang::mail('delay', [DateTime::formatTimeElapsed($q['rewardMailDelay'] * 1000)]);
|
||||
}
|
||||
else if ($npcId = DB::World()->selectCell('SELECT `Sender` FROM achievement_reward WHERE `MailTemplateId` = ?d', $this->typeId))
|
||||
{
|
||||
|
||||
@@ -151,7 +151,7 @@ class ObjectBaseResponse extends TemplateResponse implements ICache
|
||||
$buff = Lang::spell('spellModOp', 4).Lang::main('colon').Util::createNumRange($min, $max);
|
||||
|
||||
// since Veins don't have charges anymore, the timer is questionable
|
||||
$infobox[] = $restock > 1 ? '[tooltip name=restock]'.Lang::gameObject('restock', [Util::formatTime($restock * 1000)]).'[/tooltip][span class=tip tooltip=restock]'.$buff.'[/span]' : $buff;
|
||||
$infobox[] = $restock > 1 ? '[tooltip name=restock]'.Lang::gameObject('restock', [DateTime::formatTimeElapsed($restock * 1000)]).'[/tooltip][span class=tip tooltip=restock]'.$buff.'[/span]' : $buff;
|
||||
}
|
||||
|
||||
// meeting stone [minLevel, maxLevel, zone]
|
||||
@@ -177,7 +177,7 @@ class ObjectBaseResponse extends TemplateResponse implements ICache
|
||||
$buff .= Lang::main('colon').'[ul]';
|
||||
|
||||
if ($minTime > 1) // sign shenannigans reverse the display order
|
||||
$buff .= '[li]'.Lang::game('duration').Lang::main('colon').Util::createNumRange(-$maxTime, -$minTime, fn: fn($x) => Util::FormatTime(-$x * 1000, true)).'[/li]';
|
||||
$buff .= '[li]'.Lang::game('duration').Lang::main('colon').Util::createNumRange(-$maxTime, -$minTime, fn: fn($x) => DateTime::formatTimeElapsed(-$x * 1000)).'[/li]';
|
||||
|
||||
if ($minPlayer)
|
||||
$buff .= '[li]'.Lang::main('players').Lang::main('colon').Util::createNumRange($minPlayer, $maxPlayer).'[/li]';
|
||||
|
||||
@@ -197,7 +197,7 @@ class QuestBaseResponse extends TemplateResponse implements ICache
|
||||
|
||||
// timer
|
||||
if ($_ = $this->subject->getField('timeLimit'))
|
||||
$infobox[] = Lang::quest('timer').Util::formatTime($_ * 1000);
|
||||
$infobox[] = Lang::quest('timer').DateTime::formatTimeElapsedFloat($_ * 1000);
|
||||
|
||||
$startEnd = DB::Aowow()->select('SELECT * FROM ?_quests_startend WHERE `questId` = ?d', $this->typeId);
|
||||
|
||||
@@ -1159,7 +1159,7 @@ class QuestBaseResponse extends TemplateResponse implements ICache
|
||||
'header' => array(
|
||||
$rmtId,
|
||||
null,
|
||||
$delay ? Lang::mail('mailIn', [Util::formatTime($delay * 1000)]) : null,
|
||||
$delay ? Lang::mail('mailIn', [DateTime::formatTimeElapsed($delay * 1000)]) : null,
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -228,7 +228,7 @@ class SpellBaseResponse extends TemplateResponse implements ICache
|
||||
$this->castTime = $this->subject->createCastTimeForCurrent(false, false);
|
||||
$this->level = $this->subject->getField('spellLevel');
|
||||
$this->rangeName = $this->subject->getField('rangeText', true);
|
||||
$this->gcd = Util::formatTime($this->subject->getField('startRecoveryTime'));
|
||||
$this->gcd = DateTime::formatTimeElapsedFloat($this->subject->getField('startRecoveryTime'));
|
||||
$this->school = $this->fmtStaffTip(Lang::getMagicSchools($this->subject->getField('schoolMask')), Util::asHex($this->subject->getField('schoolMask')));
|
||||
$this->dispel = $this->subject->getField('dispelType') ? Lang::game('dt', $this->subject->getField('dispelType')) : null;
|
||||
$this->mechanic = $this->subject->getField('mechanic') ? Lang::game('me', $this->subject->getField('mechanic')) : null;
|
||||
@@ -258,12 +258,12 @@ class SpellBaseResponse extends TemplateResponse implements ICache
|
||||
$this->stances = Lang::getStances($this->subject->getField('stanceMask'));
|
||||
|
||||
if (($_ = $this->subject->getField('recoveryTime')) && $_ > 0)
|
||||
$this->cooldown = Util::formatTime($_);
|
||||
$this->cooldown = DateTime::formatTimeElapsedFloat($_);
|
||||
else if (($_ = $this->subject->getField('recoveryCategory')) && $_ > 0)
|
||||
$this->cooldown = Util::formatTime($_);
|
||||
$this->cooldown = DateTime::formatTimeElapsedFloat($_);
|
||||
|
||||
if (($_ = $this->subject->getField('duration')) && $_ > 0)
|
||||
$this->duration = Util::formatTime($_);
|
||||
$this->duration = DateTime::formatTimeElapsedFloat($_);
|
||||
|
||||
|
||||
/**************/
|
||||
@@ -1703,7 +1703,7 @@ class SpellBaseResponse extends TemplateResponse implements ICache
|
||||
$_footer['radius'] = Lang::spell('_radius').$this->subject->getField('effect'.$i.'RadiusMax').' '.Lang::spell('_distUnit');
|
||||
|
||||
if ($this->subject->getField('effect'.$i.'Periode') > 0)
|
||||
$_footer['interval'] = Lang::spell('_interval').Util::formatTime($this->subject->getField('effect'.$i.'Periode'));
|
||||
$_footer['interval'] = Lang::spell('_interval').DateTime::formatTimeElapsedFloat($this->subject->getField('effect'.$i.'Periode'));
|
||||
|
||||
if ($_ = $this->subject->getField('effect'.$i.'Mechanic'))
|
||||
$_footer['mechanic'] = Lang::game('mechanic').Lang::main('colon').Lang::game('me', $_);
|
||||
@@ -1712,7 +1712,7 @@ class SpellBaseResponse extends TemplateResponse implements ICache
|
||||
{
|
||||
$_footer['proc'] = $procData['chance'] < 0 ? Lang::spell('ppm', [-$procData['chance']]) : Lang::spell('procChance', [$procData['chance']]);
|
||||
if ($procData['cooldown'])
|
||||
$_footer['procCD'] = Lang::game('cooldown', [Util::formatTime($procData['cooldown'], true)]);
|
||||
$_footer['procCD'] = Lang::game('cooldown', [DateTime::formatTimeElapsed($procData['cooldown'] * 1000)]);
|
||||
}
|
||||
|
||||
// Effect Name
|
||||
|
||||
@@ -46,7 +46,7 @@ class UserBaseResponse extends TemplateResponse
|
||||
// do not display system account
|
||||
if (!$this->user['id'])
|
||||
$this->generateNotFound(Lang::user('notFound', [$pageParam]));
|
||||
}
|
||||
}
|
||||
|
||||
protected function generate() : void
|
||||
{
|
||||
@@ -74,14 +74,16 @@ class UserBaseResponse extends TemplateResponse
|
||||
}
|
||||
|
||||
if ($this->user['joinDate'])
|
||||
$infobox[] = Lang::user('joinDate') . '[tooltip name=joinDate]'. date('l, G:i:s', $this->user['joinDate']). '[/tooltip][span class=tip tooltip=joinDate]'. date(Lang::main('dateFmtShort'), $this->user['joinDate']). '[/span]';
|
||||
$infobox[] = Lang::user('joinDate') . '[tooltip name=joinDate]'. date('l, G:i:s', $this->user['joinDate']). '[/tooltip][span class=tip tooltip=joinDate]'.(new DateTime())->formatDate($this->user['joinDate']). '[/span]';
|
||||
if ($this->user['prevLogin'])
|
||||
$infobox[] = Lang::user('lastLogin') . '[tooltip name=lastLogin]'.date('l, G:i:s', $this->user['prevLogin']).'[/tooltip][span class=tip tooltip=lastLogin]'.date(Lang::main('dateFmtShort'), $this->user['prevLogin']).'[/span]';
|
||||
$infobox[] = Lang::user('lastLogin') . '[tooltip name=lastLogin]'.date('l, G:i:s', $this->user['prevLogin']).'[/tooltip][span class=tip tooltip=lastLogin]'.(new DateTime())->formatDate($this->user['prevLogin']).'[/span]';
|
||||
if ($groups)
|
||||
$infobox[] = Lang::user('userGroups') . implode(', ', $groups);
|
||||
|
||||
$infobox[] = Lang::user('consecVisits'). $this->user['consecutiveVisits'];
|
||||
$infobox[] = Lang::main('siteRep') . Lang::nf($this->user['sumRep']);
|
||||
|
||||
if ($this->user['sumRep'])
|
||||
$infobox[] = Lang::main('siteRep') . Lang::nf($this->user['sumRep']);
|
||||
|
||||
if ($infobox)
|
||||
$this->infobox = new InfoboxMarkup($infobox, ['allow' => Markup::CLASS_STAFF], 'infobox-contents0');
|
||||
@@ -298,6 +300,9 @@ class UserBaseResponse extends TemplateResponse
|
||||
|
||||
[$sum, $nRatings] = $co;
|
||||
|
||||
if (!$sum)
|
||||
return null;
|
||||
|
||||
return Lang::user('comments').$sum.($nRatings ? ' [small]([tooltip=tooltip_totalratings]'.$nRatings.'[/tooltip])[/small]' : '');
|
||||
}
|
||||
|
||||
@@ -313,6 +318,9 @@ class UserBaseResponse extends TemplateResponse
|
||||
|
||||
[$sum, $nSticky, $nPending] = $ss;
|
||||
|
||||
if (!$sum)
|
||||
return null;
|
||||
|
||||
$buff = [];
|
||||
if ($nSticky || $nPending)
|
||||
{
|
||||
@@ -341,6 +349,9 @@ class UserBaseResponse extends TemplateResponse
|
||||
|
||||
[$sum, $nSticky, $nPending] = $vi;
|
||||
|
||||
if (!$sum)
|
||||
return null;
|
||||
|
||||
$buff = [];
|
||||
if ($nSticky || $nPending)
|
||||
{
|
||||
@@ -373,6 +384,9 @@ class UserBaseResponse extends TemplateResponse
|
||||
if ($nReplies)
|
||||
$buff[] = '[tooltip=replies]'.$nReplies.'[/tooltip]';
|
||||
|
||||
if (!$buff)
|
||||
return null;
|
||||
|
||||
return Lang::user('posts').($nTopics + $nReplies).($buff ? ' [small]('.implode(' + ', $buff).')[/small]' : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ trait SmartHelper
|
||||
private function numRange(int $min, int $max, bool $isTime) : string
|
||||
{
|
||||
if ($isTime)
|
||||
return Util::createNumRange($min, $max, ' – ', fn($x) => Util::formatTime($x, true));
|
||||
return Util::createNumRange($min, $max, ' – ', fn($x) => DateTime::formatTimeElapsed($x));
|
||||
|
||||
return Util::createNumRange($min, $max, ' – ');
|
||||
}
|
||||
@@ -32,7 +32,7 @@ trait SmartHelper
|
||||
if (!$time)
|
||||
return '';
|
||||
|
||||
return Util::formatTime($time * ($isMilliSec ? 1 : 1000), false);
|
||||
return DateTime::formatTimeElapsedFloat($time * ($isMilliSec ? 1 : 1000));
|
||||
}
|
||||
|
||||
private function castFlags(int $flags) : string
|
||||
|
||||
@@ -653,7 +653,7 @@ trait spawnHelper
|
||||
$label = [Lang::npc('waypoint').Lang::main('colon').$p['point']];
|
||||
|
||||
if ($p['wait'])
|
||||
$label[] = Lang::npc('wait').Lang::main('colon').Util::formatTime($p['wait'], false);
|
||||
$label[] = Lang::npc('wait').Lang::main('colon').DateTime::formatTimeElapsedFloat($p['wait']);
|
||||
|
||||
$opts = array( // \0 doesn't get printed and tricks Util::toJSON() into handling this as a string .. i feel slightly dirty now
|
||||
'label' => "\0$<br /><span class=\"q0\">".implode('<br />', $label).'</span>',
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 = [];
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -965,7 +965,7 @@ class ItemList extends DBTypeList
|
||||
$extra = [];
|
||||
if ($cd >= 5000 && $this->curTpl['spellTrigger'.$j] != SPELL_TRIGGER_EQUIP)
|
||||
{
|
||||
$pt = Util::parseTime($cd);
|
||||
$pt = DateTime::parse($cd);
|
||||
if (count(array_filter($pt)) == 1) // simple time: use simple method
|
||||
$extra[] = Lang::formatTime($cd, 'item', 'cooldown');
|
||||
else // build block with generic time
|
||||
|
||||
@@ -668,7 +668,7 @@ class SpellList extends DBTypeList
|
||||
else if ($noInstant && !in_array($this->curTpl['typeCat'], [11, 7, -3, -6, -8, 0]) && !($this->curTpl['cuFlags'] & SPELL_CU_TALENTSPELL))
|
||||
return '';
|
||||
else
|
||||
return $short ? Lang::formatTime($this->curTpl['castTime'] * 1000, 'spell', 'castTime') : Util::formatTime($this->curTpl['castTime'] * 1000);
|
||||
return $short ? Lang::formatTime($this->curTpl['castTime'] * 1000, 'spell', 'castTime') : DateTime::formatTimeElapsedFloat($this->curTpl['castTime'] * 1000);
|
||||
}
|
||||
|
||||
private function createCooldownForCurrent() : string
|
||||
|
||||
@@ -32,6 +32,7 @@ if ($error)
|
||||
require_once 'includes/defines.php';
|
||||
require_once 'includes/locale.class.php';
|
||||
require_once 'localization/lang.class.php';
|
||||
require_once 'localization/datetime.class.php';
|
||||
require_once 'includes/libs/DbSimple/Generic.php'; // Libraray: http://en.dklab.ru/lib/DbSimple (using variant: https://github.com/ivan1986/DbSimple/tree/master)
|
||||
require_once 'includes/database.class.php'; // wrap DBSimple
|
||||
require_once 'includes/utilities.php'; // helper functions
|
||||
|
||||
@@ -148,110 +148,6 @@ abstract class Util
|
||||
return $money;
|
||||
}
|
||||
|
||||
public static function parseTime(int $msec) : array
|
||||
{
|
||||
$time = [0, 0, 0, 0, 0];
|
||||
|
||||
if ($_ = ($msec % 1000))
|
||||
$time[0] = $_;
|
||||
|
||||
$sec = $msec / 1000;
|
||||
|
||||
if ($sec >= 3600 * 24)
|
||||
{
|
||||
$time[4] = floor($sec / 3600 / 24);
|
||||
$sec -= $time[4] * 3600 * 24;
|
||||
}
|
||||
|
||||
if ($sec >= 3600)
|
||||
{
|
||||
$time[3] = floor($sec / 3600);
|
||||
$sec -= $time[3] * 3600;
|
||||
}
|
||||
|
||||
if ($sec >= 60)
|
||||
{
|
||||
$time[2] = floor($sec / 60);
|
||||
$sec -= $time[2] * 60;
|
||||
}
|
||||
|
||||
if ($sec > 0)
|
||||
{
|
||||
$time[1] = (int)$sec;
|
||||
$sec -= $time[1];
|
||||
}
|
||||
|
||||
return $time;
|
||||
}
|
||||
|
||||
public static function formatTime(int $msec, bool $short = false) : string
|
||||
{
|
||||
[$ms, $s, $m, $h, $d] = self::parseTime(abs($msec));
|
||||
// \u00A0 is  , but also usable by js
|
||||
|
||||
if ($short)
|
||||
{
|
||||
if ($_ = round($d / 365))
|
||||
return $_."\u{00A0}".Lang::timeUnits('ab', 0);
|
||||
if ($_ = round($d / 30))
|
||||
return $_."\u{00A0}".Lang::timeUnits('ab', 1);
|
||||
if ($_ = round($d / 7))
|
||||
return $_."\u{00A0}".Lang::timeUnits('ab', 2);
|
||||
if ($_ = round($d))
|
||||
return $_."\u{00A0}".Lang::timeUnits('ab', 3);
|
||||
if ($_ = round($h))
|
||||
return $_."\u{00A0}".Lang::timeUnits('ab', 4);
|
||||
if ($_ = round($m))
|
||||
return $_."\u{00A0}".Lang::timeUnits('ab', 5);
|
||||
if ($_ = round($s + $ms / 1000, 2))
|
||||
return $_."\u{00A0}".Lang::timeUnits('ab', 6);
|
||||
if ($ms)
|
||||
return $ms."\u{00A0}".Lang::timeUnits('ab', 7);
|
||||
|
||||
return "0\u{00A0}".Lang::timeUnits('ab', 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
$_ = $d + $h / 24;
|
||||
if ($_ > 1 && !($_ % 365)) // whole years
|
||||
return round(($d + $h / 24) / 365, 2)."\u{00A0}".Lang::timeUnits($d / 365 == 1 && !$h ? 'sg' : 'pl', 0);
|
||||
if ($_ > 1 && !($_ % 30)) // whole months
|
||||
return round(($d + $h / 24) / 30, 2)."\u{00A0}".Lang::timeUnits($d / 30 == 1 && !$h ? 'sg' : 'pl', 1);
|
||||
if ($_ > 1 && !($_ % 7)) // whole weeks
|
||||
return round(($d + $h / 24) / 7, 2)."\u{00A0}".Lang::timeUnits($d / 7 == 1 && !$h ? 'sg' : 'pl', 2);
|
||||
if ($d)
|
||||
return round($d + $h / 24, 2)."\u{00A0}".Lang::timeUnits($d == 1 && !$h ? 'sg' : 'pl', 3);
|
||||
if ($h)
|
||||
return round($h + $m / 60, 2)."\u{00A0}".Lang::timeUnits($h == 1 && !$m ? 'sg' : 'pl', 4);
|
||||
if ($m)
|
||||
return round($m + $s / 60, 2)."\u{00A0}".Lang::timeUnits($m == 1 && !$s ? 'sg' : 'pl', 5);
|
||||
if ($s)
|
||||
return round($s + $ms / 1000, 2)."\u{00A0}".Lang::timeUnits($s == 1 && !$ms ? 'sg' : 'pl', 6);
|
||||
if ($ms)
|
||||
return $ms."\u{00A0}".Lang::timeUnits($ms == 1 ? 'sg' : 'pl', 7);
|
||||
|
||||
return "0\u{00A0}".Lang::timeUnits('pl', 6);
|
||||
}
|
||||
}
|
||||
|
||||
public static function formatTimeDiff(int $sec) : string
|
||||
{
|
||||
$delta = abs(time() - $sec);
|
||||
|
||||
[, $s, $m, $h, $d] = self::parseTime($delta * 1000);
|
||||
|
||||
if ($delta > (1 * MONTH)) // use absolute
|
||||
return date(Lang::main('dateFmtLong'), $sec);
|
||||
else if ($delta > (2 * DAY)) // days ago
|
||||
return Lang::main('timeAgo', [$d . ' ' . Lang::timeUnits('pl', 3)]);
|
||||
else if ($h) // hours, minutes ago
|
||||
return Lang::main('timeAgo', [$h . ' ' . Lang::timeUnits('ab', 4) . ' ' . $m . ' ' . Lang::timeUnits('ab', 5)]);
|
||||
else if ($m) // minutes, seconds ago
|
||||
return Lang::main('timeAgo', [$m . ' ' . Lang::timeUnits('ab', 5) . ' ' . $s . ' ' . Lang::timeUnits('ab', 6)]);
|
||||
else // seconds ago
|
||||
return Lang::main('timeAgo', [$s . ' ' . Lang::timeUnits($s == 1 ? 'sg' : 'pl', 6)]);
|
||||
}
|
||||
|
||||
// pageTexts, questTexts and mails
|
||||
public static function parseHtmlText(string|array $text, bool $markdown = false) : string|array
|
||||
{
|
||||
@@ -1264,7 +1160,7 @@ abstract class Util
|
||||
if ($expiration)
|
||||
{
|
||||
$vars += array_fill(0, 9, null); // vsprintf requires all unused indizes to also be set...
|
||||
$vars[9] = Util::formatTime($expiration * 1000);
|
||||
$vars[9] = DateTime::formatTimeElapsed($expiration * 1000, 0);
|
||||
}
|
||||
|
||||
if ($vars)
|
||||
|
||||
218
localization/datetime.class.php
Normal file
218
localization/datetime.class.php
Normal file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
|
||||
namespace Aowow;
|
||||
|
||||
if (!defined('AOWOW_REVISION'))
|
||||
die('illegal access');
|
||||
|
||||
|
||||
class DateTime extends \DateTimeImmutable
|
||||
{
|
||||
// in msec yr mo w d h m s ms
|
||||
private const /* array */ RANGE = [31557600000, 2629800000, 604800000, 86400000, 3600000, 60000, 1000, 1];
|
||||
private const /* string */ NBSP = "\u{00A0}"; // \u00A0 is usable by js
|
||||
|
||||
public function __construct(int $seconds = 0)
|
||||
{
|
||||
$datetime = $seconds ? date(DATE_ATOM, $seconds) : 'now';
|
||||
parent::__construct($datetime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adaptive, human-readable format of a date
|
||||
* exact date if larger than 1 month
|
||||
* relative days/time if smaller than 1 month
|
||||
*
|
||||
* @param int $timestamp unix timestamp to display
|
||||
* @param bool $withTime [optional] append time on exact dates
|
||||
* @return string adaptive date/time string
|
||||
*/
|
||||
public function formatDate(int $timestamp, bool $withTime = false) : string
|
||||
{
|
||||
$txt = '';
|
||||
$elapsed = abs($this->getTimestamp() - $timestamp);
|
||||
|
||||
$today = new DateTime();
|
||||
$eventDay = new DateTime(time() - $elapsed);
|
||||
|
||||
$todayMidnight = $today->setTime(0, 0);
|
||||
$eventDayMidnight = $eventDay->setTime(0, 0);
|
||||
|
||||
$delta = $todayMidnight->diff($eventDayMidnight, true)->days;
|
||||
|
||||
if ($elapsed >= 2592000) /* More than a month ago */
|
||||
$txt = Lang::main('date_on') . $eventDay->formatDateSimple($withTime);
|
||||
else if ($delta > 1)
|
||||
$txt = Lang::main('ddaysago', [$delta]);
|
||||
else if ($elapsed >= 43200)
|
||||
{
|
||||
if ($today->format('j') == $eventDay->format('j'))
|
||||
$txt = Lang::main('today');
|
||||
else
|
||||
$txt = Lang::main('yesterday');
|
||||
|
||||
$txt = $eventDay->formatTimeSimple($txt);
|
||||
}
|
||||
else /* Less than 12 hours ago */
|
||||
$txt = Lang::main('date_ago', [self::formatTimeElapsed($elapsed * 1000)]);
|
||||
|
||||
return $txt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Human-readable format of a date. Optionally append time of day.
|
||||
*
|
||||
* @param bool $withTime [optional] affixes day time
|
||||
* @return string a formatted date string.
|
||||
*/
|
||||
public function formatDateSimple(bool $withTime = false) : string
|
||||
{
|
||||
$txt = '';
|
||||
$day = $this->format('d');
|
||||
$month = $this->format('m');
|
||||
$year = $this->format('Y');
|
||||
|
||||
if ($year <= 1970)
|
||||
$txt .= Lang::main('unknowndate_stc');
|
||||
else
|
||||
$txt .= Lang::main('date_simple', [$day, $month, $year]);
|
||||
|
||||
if ($withTime)
|
||||
$txt = $this->formatTimeSimple($txt);
|
||||
|
||||
return $txt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Human-readable format of the time of day.
|
||||
*
|
||||
* @param string $txt [optional] text to affeix the day time to
|
||||
* @param bool $noPrefix [optional] don't use " at " to affix time of day to $txt
|
||||
* @return string a formatted time of day string.
|
||||
*/
|
||||
public function formatTimeSimple(string $txt = '', bool $noPrefix = false) : string
|
||||
{
|
||||
$hours = $this->format('G');
|
||||
$minutes = $this->format('i');
|
||||
|
||||
$txt .= ($noPrefix ? ' ' : Lang::main('date_at'));
|
||||
|
||||
if ($hours == 12)
|
||||
$txt .= Lang::main('noon');
|
||||
else if ($hours == 0)
|
||||
$txt .= Lang::main('midnight');
|
||||
else if ($hours > 12)
|
||||
$txt .= ($hours - 12) . ':' . $minutes . ' ' . Lang::main('pm');
|
||||
else
|
||||
$txt .= $hours . ':' . $minutes . ' ' . Lang::main('am');
|
||||
|
||||
return $txt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate component values from timestamp
|
||||
*
|
||||
* @param int $msec time in milliseconds to parse
|
||||
* @return int[] [msec, sec, min, hr, day]
|
||||
*/
|
||||
public static function parse(int $msec) : array
|
||||
{
|
||||
$time = [0, 0, 0, 0, 0];
|
||||
$msec = abs($msec);
|
||||
|
||||
for ($i = 3; $i < count(self::RANGE); ++$i)
|
||||
{
|
||||
if ($msec < self::RANGE[$i])
|
||||
continue;
|
||||
|
||||
$time[7 - $i] = intVal($msec / self::RANGE[$i]);
|
||||
$msec %= self::RANGE[$i];
|
||||
}
|
||||
|
||||
return $time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Human-readable longform format of a timespan.
|
||||
*
|
||||
* @param int $delay time in milliseconds to format
|
||||
* @return string a formatted time string. If an error occured "n/a" (localized) is returned
|
||||
*/
|
||||
public static function formatTimeElapsedFloat(int $delay) : string
|
||||
{
|
||||
$delay = max($delay, 1);
|
||||
|
||||
for ($i = 0; $i < count(self::RANGE); ++$i)
|
||||
{
|
||||
if ($delay < self::RANGE[$i])
|
||||
continue;
|
||||
|
||||
$v = round($delay / self::RANGE[$i], 2);
|
||||
return $v . self::NBSP . Lang::timeUnits($v === 1.0 ? 'sg' : 'pl', $i);
|
||||
}
|
||||
|
||||
return Lang::main('n_a');
|
||||
}
|
||||
|
||||
/**
|
||||
* Human-readable format of a timespan.
|
||||
*
|
||||
* @param int $delay time in milliseconds to format
|
||||
* @param int $maxRange [optional] time unit index - 0 (year) ... 7 (milliseconds)
|
||||
* @return string a formatted time string. If an error occured "n/a" (localized) is returned
|
||||
*/
|
||||
public static function formatTimeElapsed(int $delay, int $maxRange = 3) : string
|
||||
{
|
||||
if ($maxRange > 7 || $maxRange < 0)
|
||||
$maxRange = 3; // default: days
|
||||
|
||||
$subunit = [1, 3, 3, -1, 5, -1, 7, -1];
|
||||
$delay = max($delay, 1);
|
||||
|
||||
for ($i = $maxRange; $i < count(self::RANGE); ++$i)
|
||||
{
|
||||
if ($delay >= self::RANGE[$i])
|
||||
{
|
||||
$i1 = $i;
|
||||
$v1 = floor($delay / self::RANGE[$i1]);
|
||||
|
||||
if ($subunit[$i1] != -1)
|
||||
{
|
||||
$i2 = $subunit[$i1];
|
||||
$delay %= self::RANGE[$i1];
|
||||
$v2 = floor($delay / self::RANGE[$i2]);
|
||||
|
||||
if ($v2 > 0)
|
||||
return self::OMG($v1, $i1, true) . self::NBSP . self::OMG($v2, $i2, true);
|
||||
}
|
||||
|
||||
return self::OMG($v1, $i1, false);
|
||||
}
|
||||
}
|
||||
|
||||
return Lang::main('n_a');
|
||||
}
|
||||
|
||||
/**
|
||||
* internal number formatter
|
||||
*
|
||||
* @param int $value unit value
|
||||
* @param int $unit time unit index 0 (year) ... 7 (milliseconds)
|
||||
* @param bool $abbrv use abbreviation
|
||||
* @return string value + unit
|
||||
*/
|
||||
private static function OMG(int $value, int $unit, bool $abbrv) : string
|
||||
{
|
||||
if ($abbrv && !Lang::timeUnits('ab', $unit))
|
||||
$abbrv = false;
|
||||
|
||||
return $value .= self::NBSP . match(true)
|
||||
{
|
||||
$abbrv => Lang::timeUnits('ab', $unit),
|
||||
$value == 1 => Lang::timeUnits('sg', $unit),
|
||||
default => Lang::timeUnits('pl', $unit)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -535,7 +535,7 @@ class Lang
|
||||
if ($msec < 0)
|
||||
$msec = 0;
|
||||
|
||||
$time = Util::parseTime($msec); // [$ms, $s, $m, $h, $d]
|
||||
$time = DateTime::parse($msec); // [$ms, $s, $m, $h, $d]
|
||||
$mult = [0, 1000, 60, 60, 24];
|
||||
$total = 0;
|
||||
$ref = [];
|
||||
@@ -552,33 +552,22 @@ class Lang
|
||||
if (!$msec)
|
||||
return self::vspf($ref[0], [0]);
|
||||
|
||||
if ($concat)
|
||||
{
|
||||
for ($i = 4; $i > 0; $i--)
|
||||
{
|
||||
$total += $time[$i];
|
||||
if (isset($ref[$i]) && ($total || ($i == 1 && !$result)))
|
||||
{
|
||||
$result[] = self::vspf($ref[$i], [$total]);
|
||||
$total = 0;
|
||||
}
|
||||
else
|
||||
$total *= $mult[$i];
|
||||
}
|
||||
|
||||
return implode(', ', $result);
|
||||
}
|
||||
|
||||
for ($i = 4; $i > 0; $i--)
|
||||
{
|
||||
$total += $time[$i];
|
||||
if (isset($ref[$i]) && ($total || $i == 1))
|
||||
return self::vspf($ref[$i], [$total + ($time[$i-1] ?? 0) / $mult[$i]]);
|
||||
if (isset($ref[$i]) && ($total || ($i == 1 && !$result)))
|
||||
{
|
||||
if (!$concat)
|
||||
return self::vspf($ref[$i], [$total + ($time[$i-1] ?? 0) / $mult[$i]]);
|
||||
|
||||
$result[] = self::vspf($ref[$i], [$total]);
|
||||
$total = 0;
|
||||
}
|
||||
else
|
||||
$total *= $mult[$i];
|
||||
}
|
||||
|
||||
return '';
|
||||
return implode(', ', $result);
|
||||
}
|
||||
|
||||
private static function vspf(null|array|string $var, array $args = []) : null|array|string
|
||||
|
||||
@@ -134,8 +134,25 @@ $lang = array(
|
||||
'dateFmtShort' => "d.m.Y",
|
||||
'dateFmtLong' => "d.m.Y \u\m H:i",
|
||||
'dateFmtIntl' => "d. MMMM y",
|
||||
'timeAgo' => 'vor %s',
|
||||
'nfSeparators' => ['.', ','],
|
||||
'n_a' => "n. v.",
|
||||
|
||||
// date time
|
||||
'date' => "Datum",
|
||||
'date_colon' => "Datum: ",
|
||||
'date_on' => "am ",
|
||||
'date_ago' => "vor %s",
|
||||
'date_at' => " um ",
|
||||
'date_to' => " bis ",
|
||||
'date_simple' => '%1$d.%2$d.%3$d',
|
||||
'unknowndate' => "Unbekanntes Datum",
|
||||
'ddaysago' => "vor %d Tagen",
|
||||
'today' => "heute",
|
||||
'yesterday' => "gestern",
|
||||
'noon' => "Mittag",
|
||||
'midnight' => "Mitternacht",
|
||||
'am' => "vormittags",
|
||||
'pm' => "nachmittags",
|
||||
|
||||
// error
|
||||
'intError' => "Ein interner Fehler ist aufgetreten.",
|
||||
@@ -1656,7 +1673,6 @@ $lang = array(
|
||||
'_rankRange' => "Rang: %d - %d",
|
||||
'_showXmore' => "Zeige %d weitere",
|
||||
|
||||
'n_a' => "n. v.",
|
||||
'normal' => "Normal",
|
||||
'special' => "Besonders",
|
||||
|
||||
|
||||
@@ -134,8 +134,25 @@ $lang = array(
|
||||
'dateFmtShort' => "Y/m/d",
|
||||
'dateFmtLong' => "Y/m/d \a\\t g:i A",
|
||||
'dateFmtIntl' => "MMMM d, y",
|
||||
'timeAgo' => "%s ago",
|
||||
'nfSeparators' => [',', '.'],
|
||||
'n_a' => "n/a",
|
||||
|
||||
// date time
|
||||
'date' => "Date",
|
||||
'date_colon' => "Date: ",
|
||||
'date_on' => "on ",
|
||||
'date_ago' => "%s ago",
|
||||
'date_at' => " at ",
|
||||
'date_to' => " to ",
|
||||
'date_simple' => '%2$d/%1$d/%3$d',
|
||||
'unknowndate' => "Unknown date",
|
||||
'ddaysago' => "%d days ago",
|
||||
'today' => "today",
|
||||
'yesterday' => "yesterday",
|
||||
'noon' => "noon",
|
||||
'midnight' => "midnight",
|
||||
'am' => "AM",
|
||||
'pm' => "PM",
|
||||
|
||||
// error
|
||||
'intError' => "An internal error has occurred.",
|
||||
@@ -1656,7 +1673,6 @@ $lang = array(
|
||||
'_rankRange' => "Rank: %d - %d",
|
||||
'_showXmore' => "Show %d More",
|
||||
|
||||
'n_a' => "n/a",
|
||||
'normal' => "Normal",
|
||||
'special' => "Special",
|
||||
|
||||
|
||||
@@ -134,8 +134,25 @@ $lang = array(
|
||||
'dateFmtShort' => "d/m/Y",
|
||||
'dateFmtLong' => "d/m/Y \a \l\a\s g:i A",
|
||||
'dateFmtIntl' => "d 'de' MMMM 'de' y",
|
||||
'timeAgo' => 'hace %s',
|
||||
'nfSeparators' => ['.', ','],
|
||||
'n_a' => "n/d",
|
||||
|
||||
// date time
|
||||
'date' => "Fecha",
|
||||
'date_colon' => "Fecha: ",
|
||||
'date_on' => "el ",
|
||||
'date_ago' => "hace %s",
|
||||
'date_at' => " a las ",
|
||||
'date_to' => " al ",
|
||||
'date_simple' => '%1$d/%2$d/%3$d',
|
||||
'unknowndate' => "Fecha desconocida",
|
||||
'ddaysago' => "Hace %d días",
|
||||
'today' => "hoy",
|
||||
'yesterday' => "ayer",
|
||||
'noon' => "medio día",
|
||||
'midnight' => "medianoche",
|
||||
'am' => "a.m.",
|
||||
'pm' => "p.m.",
|
||||
|
||||
// error
|
||||
'intError' => "Un error interno ha ocurrido.",
|
||||
@@ -1656,7 +1673,6 @@ $lang = array(
|
||||
'_rankRange' => "Rango: %d - %d",
|
||||
'_showXmore' => "Mostrar %d más",
|
||||
|
||||
'n_a' => "n/d",
|
||||
'normal' => "Normal",
|
||||
'special' => "Especial",
|
||||
|
||||
|
||||
@@ -134,8 +134,25 @@ $lang = array(
|
||||
'dateFmtShort' => "Y-m-d",
|
||||
'dateFmtLong' => "Y-m-d à g:i A",
|
||||
'dateFmtIntl' => "d MMMM y",
|
||||
'timeAgo' => 'il y a %s',
|
||||
'nfSeparators' => [' ', ','],
|
||||
'n_a' => "n/d",
|
||||
|
||||
// date time
|
||||
'date' => "Date",
|
||||
'date_colon' => "Date : ",
|
||||
'date_on' => "le ",
|
||||
'date_ago' => "il y a %s",
|
||||
'date_at' => " à ",
|
||||
'date_to' => " à ",
|
||||
'date_simple' => '%1$d-%2$d-%3$d',
|
||||
'unknowndate' => "Date inconnue",
|
||||
'ddaysago' => "%d jours avant",
|
||||
'today' => "aujourd'hui",
|
||||
'yesterday' => "hier",
|
||||
'noon' => "midi",
|
||||
'midnight' => "minuit",
|
||||
'am' => "AM",
|
||||
'pm' => "PM",
|
||||
|
||||
// error
|
||||
'intError' => "[An internal error occured.]",
|
||||
@@ -1656,7 +1673,6 @@ $lang = array(
|
||||
'_rankRange' => "Rang : %d - %d",
|
||||
'_showXmore' => "En afficher %d de plus",
|
||||
|
||||
'n_a' => "n/d",
|
||||
'normal' => "Standard",
|
||||
'special' => "Spécial",
|
||||
|
||||
|
||||
@@ -134,8 +134,25 @@ $lang = array(
|
||||
'dateFmtShort' => "Y-m-d",
|
||||
'dateFmtLong' => "Y-m-d в g:i A",
|
||||
'dateFmtIntl' => "d MMMM y г.",
|
||||
'timeAgo' => '%s назад',
|
||||
'nfSeparators' => [' ', ','],
|
||||
'n_a' => "нет",
|
||||
|
||||
// date time
|
||||
'date' => "По дате",
|
||||
'date_colon' => "Дата: ",
|
||||
'date_on' => "на ",
|
||||
'date_ago' => "%s назад",
|
||||
'date_at' => " в ",
|
||||
'date_to' => " в ",
|
||||
'date_simple' => '%1$d.%2$d.%3$d',
|
||||
'unknowndate' => "Неизвестная дата",
|
||||
'ddaysago' => "%d дней назад",
|
||||
'today' => "сегодня",
|
||||
'yesterday' => "вчера",
|
||||
'noon' => "полдень",
|
||||
'midnight' => "полночь",
|
||||
'am' => "a.m.",
|
||||
'pm' => "p.m.",
|
||||
|
||||
// error
|
||||
'intError' => "[An internal error occured.]",
|
||||
@@ -1656,7 +1673,6 @@ $lang = array(
|
||||
'_rankRange' => "Ранг: %d - %d",
|
||||
'_showXmore' => "Показать на %d больше",
|
||||
|
||||
'n_a' => "нет",
|
||||
'normal' => "Обычный",
|
||||
'special' => "Особый",
|
||||
|
||||
|
||||
@@ -134,8 +134,25 @@ $lang = array(
|
||||
'dateFmtShort' => "Y/m/d",
|
||||
'dateFmtLong' => "Y/m/d \a\\t g:i A",
|
||||
'dateFmtIntl' => "y年M月d日",
|
||||
'timeAgo' => '%s之前',
|
||||
'nfSeparators' => [',', '.'],
|
||||
'n_a' => "n/a",
|
||||
|
||||
// date time
|
||||
'date' => "日期",
|
||||
'date_colon' => "日期:",
|
||||
'date_on' => "在 ",
|
||||
'date_ago' => "%s前",
|
||||
'date_at' => "于",
|
||||
'date_to' => "至",
|
||||
'date_simple' => '%3$d/%2$d/%1$d',
|
||||
'unknowndate' => "未知日期",
|
||||
'ddaysago' => "%d天前",
|
||||
'today' => "今日",
|
||||
'yesterday' => "昨天",
|
||||
'noon' => "正午",
|
||||
'midnight' => "午夜",
|
||||
'am' => "AM",
|
||||
'pm' => "PM",
|
||||
|
||||
// error
|
||||
'intError' => "发生内部错误。",
|
||||
@@ -1656,7 +1673,6 @@ $lang = array(
|
||||
'_rankRange' => "排名: %d - %d",
|
||||
'_showXmore' => "[Show %d More]",
|
||||
|
||||
'n_a' => "n/a",
|
||||
'normal' => "普通",
|
||||
'special' => "特殊",
|
||||
|
||||
|
||||
@@ -92,23 +92,23 @@ endif;
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="border-left: 0; border-top: 0"><?=Lang::game('duration');?></th>
|
||||
<td width="100%" style="border-top: 0"><?=($this->duration ?: '<span class="q0">'.Lang::spell('n_a').'</span>');?></td>
|
||||
<td width="100%" style="border-top: 0"><?=($this->duration ?: '<span class="q0">'.Lang::main('n_a').'</span>');?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="border-left: 0"><?=Lang::game('school'); ?></th>
|
||||
<td width="100%" style="border-top: 0"><?=($this->school ?: '<span class="q0">'.Lang::spell('n_a').'</span>');?></td>
|
||||
<td width="100%" style="border-top: 0"><?=($this->school ?: '<span class="q0">'.Lang::main('n_a').'</span>');?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="border-left: 0"><?=Lang::game('mechanic');?></th>
|
||||
<td width="100%" style="border-top: 0"><?=($this->mechanic ?:'<span class="q0">'.Lang::spell('n_a').'</span>');?></td>
|
||||
<td width="100%" style="border-top: 0"><?=($this->mechanic ?:'<span class="q0">'.Lang::main('n_a').'</span>');?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="border-left: 0"><?=Lang::game('dispelType');?></th>
|
||||
<td width="100%" style="border-top: 0"><?=($this->dispel ?: '<span class="q0">'.Lang::spell('n_a').'</span>');?></td>
|
||||
<td width="100%" style="border-top: 0"><?=($this->dispel ?: '<span class="q0">'.Lang::main('n_a').'</span>');?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="border-bottom: 0; border-left: 0"><?=Lang::spell('_gcdCategory');?></th>
|
||||
<td style="border-bottom: 0"><?=($this->gcdCat ?: '<span class="q0">'.Lang::spell('n_a').'</span>');?></td>
|
||||
<td style="border-bottom: 0"><?=($this->gcdCat ?: '<span class="q0">'.Lang::main('n_a').'</span>');?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
@@ -127,7 +127,7 @@ endif;
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?=Lang::spell('_cooldown');?></th>
|
||||
<td><?=($this->cooldown ?: '<span class="q0">'.Lang::spell('n_a').'</span>');?></td>
|
||||
<td><?=($this->cooldown ?: '<span class="q0">'.Lang::main('n_a').'</span>');?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><dfn title="<?=Lang::spell('_globCD').'">'.Lang::spell('_gcd');?></dfn></th>
|
||||
|
||||
Reference in New Issue
Block a user