feat: countdown rest time use uoj-countdown
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2023-03-14 10:53:30 +08:00
parent d42c2a2c25
commit ae1d798795
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
4 changed files with 26 additions and 18 deletions

View File

@ -90,15 +90,17 @@ $friend_links = DB::selectAll([
<ul class="list-unstyled mb-0">
<?php foreach ($countdowns as $countdown) : ?>
<?php
$enddate = strtotime($countdown['end_time']);
$nowdate = time();
$diff = ceil(($enddate - $nowdate) / (24 * 60 * 60));
$end_time = UOJTime::str2time($countdown['end_time'])->getTimestamp();
$now_time = UOJTime::$time_now->getTimestamp();
$diff = floor(($end_time - $now_time) / (24 * 60 * 60));
?>
<li>
<?php if ($diff > 0) : ?>
<?= UOJLocale::get('x days until countdown title', $countdown['title'], $diff) ?>
<?= UOJLocale::get('x days before countdown {title}', $countdown['title'], $diff) ?>
<?php elseif ($diff == 0) : ?>
<?= UOJLocale::get('{rest} before countdown {title}', $countdown['title'], $end_time - $now_time) ?>
<?php else : ?>
<?= UOJLocale::get("countdown title has begun", $countdown['title']) ?>
<?= UOJLocale::get("countdown {title} has begun", $countdown['title']) ?>
<?php endif ?>
</li>
<?php endforeach ?>

View File

@ -190,7 +190,7 @@ if ($cur_tab == 'index') {
return '标题不能为空';
}
$vdata['title'] = $title;
$vdata['title'] = HTML::escape($title);
return '';
},

View File

@ -90,11 +90,14 @@ return [
'male' => 'Male',
'female' => 'Female',
'countdowns' => 'Countdowns',
'countdown title has begun' => function($title) {
'countdown {title} has begun' => function ($title) {
return "<b>$title</b> has begun.";
},
'x days until countdown title' => function($title, $days) {
return "<b>$days</b> ".($days <= 1 ? 'day' : 'days')." until <b>$title</b>.";
'{rest} before countdown {title}' => function ($title, $rest_seconds) {
return '<b><span class="countdown" data-rest="' . $rest_seconds . '">less than a day</span></b>' . " before <b>$title</b>.";
},
'x days before countdown {title}' => function ($title, $days) {
return "<b>$days</b> " . ($days <= 1 ? 'day' : 'days') . " before <b>$title</b>.";
},
'friend links' => 'Frequently Used Links',
'server time' => 'Server Time',

View File

@ -90,10 +90,13 @@ return [
'male' => '男',
'female' => '女',
'countdowns' => '倒计时',
'countdown title has begun' => function($title) {
'countdown {title} has begun' => function($title) {
return "<b>$title</b> 已开始。";
},
'x days until countdown title' => function($title, $days) {
'{rest} before countdown {title}' => function ($title, $rest_seconds) {
return "距离 <b>$title</b> 还有 " . '<b><span class="countdown" data-rest="' . $rest_seconds . '">不足 1 天</span></b>。';
},
'x days before countdown {title}' => function($title, $days) {
return "距离 <b>$title</b> 还有 <b>$days</b> 天。";
},
'friend links' => '常用链接',