-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathutils.py
26 lines (20 loc) · 842 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import datetime
import time
def seconds_until_tomorrow():
today = datetime.date.today()
tomorrow = today + datetime.timedelta(days=1)
tomorrow_start_time = int(time.mktime(time.strptime(str(tomorrow), '%Y-%m-%d')))
current_time = int(time.time())
return tomorrow_start_time - current_time
def adjust_for_chinese(str):
SPACE = '\N{IDEOGRAPHIC SPACE}'
EXCLA = '\N{FULLWIDTH EXCLAMATION MARK}'
TILDE = '\N{FULLWIDTH TILDE}'
# strings of ASCII and full-width characters (same order)
west = ''.join(chr(i) for i in range(ord(' '), ord('~')))
east = SPACE + ''.join(chr(i) for i in range(ord(EXCLA), ord(TILDE)))
# build the translation table
full = str.maketrans(west, east)
str = str.translate(full).rstrip().split('\n')
md = f'{str[0]:^10}'
return md.translate(full)