-
Notifications
You must be signed in to change notification settings - Fork 0
/
tiny_time.py
51 lines (32 loc) · 1.22 KB
/
tiny_time.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import datetime
import string
from collections import OrderedDict
def build_int_dict():
integers = OrderedDict()
integers[0] = 'z'
for i, character in enumerate(string.ascii_lowercase):
if character == 'z':
break
integers[i+1] = character
for i, character in enumerate(string.ascii_uppercase):
if character == 'Z':
break
integers[i+26] = character
for i, character in enumerate([9,8,7,6,5,4,3,2,1]):
integers[51+i] = character
return (integers)
def build_character_dict():
numbers = build_int_dict()
characters = {v: k for k, v in numbers.items()}
return characters
def now():
numbers = build_int_dict()
now = datetime.datetime.now()
now_time = str(now).split(" ")[1]
hour, minute, secs = str(now_time).split(":")
now_date = str(now).split(" ")[0]
year, month, day = now_date.split("-")
hour_char, minute_char = (numbers[int(hour)], numbers[int(minute)])
year_char, month_char, day_char = (numbers[int(year[-2:])], numbers[int(month)], numbers[int(day)])
full_tiny_time = year_char + '_' + month_char + day_char + ':' + hour_char + minute_char
return full_tiny_time