diff --git a/auto_pt/views.py b/auto_pt/views.py index ee15d55..a5375d1 100644 --- a/auto_pt/views.py +++ b/auto_pt/views.py @@ -168,7 +168,11 @@ def restart_container(request): client = docker.from_env() # 从内部获取容器id cid = socket.gethostname() - started_at = client.api.inspect_container(cid).get('State').get('StartedAt') + started_at = client.api.inspect_container(cid).get('State').get('StartedAt')[:19] + UTC_FORMAT = "%Y-%m-%dT%H:%M:%S" + utc_time = datetime.strptime(started_at, UTC_FORMAT) + delta = datetime.now() - utc_time + if get_update_logs(): update = 'false' update_tips = '目前您使用的是最新版本!' @@ -177,7 +181,7 @@ def restart_container(request): update_tips = '已有新版本,请根据需要升级!' return render(request, 'auto_pt/restart.html', context={ - 'started_at': started_at, + 'delta': delta.total_seconds(), 'local_logs': get_git_logs(), 'update_notes': get_git_logs(master='origin/master'), 'update': update, diff --git a/templates/auto_pt/restart.html b/templates/auto_pt/restart.html index a2e830a..ab1f522 100644 --- a/templates/auto_pt/restart.html +++ b/templates/auto_pt/restart.html @@ -16,7 +16,7 @@ width="200" trigger="hover" content="如果遇到无法更新的情况,您可以选择重建容器或者进入容器命令行到项目根目录执行`git pull`命令!"> - {{ update_tips }} + 启动时间:{{ started_at }} + {{ update_tips }} + 启动时间:{{ delta }}