diff --git a/README.md b/README.md index 032001c..73994ec 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,8 @@ by 思無邪SyiMyuZya * [x] ~~支持新版協議(2015校園網更新後已失效)~~ * [x] 用文件保存/讀取用戶名與密碼(md5散列值) * [x] 重構選項解析部分的代碼,用 argparse 替代 getopt +* [x] 直觀的時間顯示格式 +* [ ] 流量可調整顯示單位 * [ ] 處理網絡異常 * [ ] ~~將服務器原始錯誤信息改為提示信息(新協議原始信息已經足夠)~~ * [ ] ~~多語言(不一定實作…因為無圖形界面時貌似不需要多語言?)~~ diff --git a/tunetctl b/tunetctl index e52e6a7..3bd7116 100755 --- a/tunetctl +++ b/tunetctl @@ -17,6 +17,7 @@ import sys import uuid from argparse import ArgumentParser, RawDescriptionHelpFormatter +from datetime import datetime, timedelta from getpass import getpass from hashlib import md5 from socket import socket, AF_INET, SOCK_DGRAM @@ -113,10 +114,13 @@ def show_status(): else: def fmtsize(s): return '{} ({}B)'.format(sizeof_fmt(int(s), si=True), s) + def fmttime(s): + return (datetime.utcfromtimestamp(int(s)) + \ + timedelta(hours=8)).strftime('%Y-%m-%dT%H:%M:%S+0800') items = [ ('Username', None), - ('Login time', None), - ('Current time', None), + ('Login time', fmttime), + ('Current time', fmttime), ('Traffic in', fmtsize), ('Traffic out', fmtsize), (None, None), # 5