Skip to content
This repository has been archived by the owner on Mar 11, 2022. It is now read-only.

Commit

Permalink
better time format
Browse files Browse the repository at this point in the history
  • Loading branch information
syimyuzya committed Apr 1, 2016
1 parent 6c4ba89 commit 5588b09
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ by 思無邪SyiMyuZya
* [x] ~~支持新版協議(2015校園網更新後已失效)~~
* [x] 用文件保存/讀取用戶名與密碼(md5散列值)
* [x] 重構選項解析部分的代碼,用 argparse 替代 getopt
* [x] 直觀的時間顯示格式
* [ ] 流量可調整顯示單位
* [ ] 處理網絡異常
* [ ] ~~將服務器原始錯誤信息改為提示信息(新協議原始信息已經足夠)~~
* [ ] ~~多語言(不一定實作…因為無圖形界面時貌似不需要多語言?)~~
8 changes: 6 additions & 2 deletions tunetctl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5588b09

Please sign in to comment.