-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdate_formater.py
More file actions
26 lines (23 loc) · 854 Bytes
/
Copy pathdate_formater.py
File metadata and controls
26 lines (23 loc) · 854 Bytes
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 time
import datetime
# Transaltions stuff
import locale;
# Seriously, it is the 21th century, and we have to do that :/
locale.setlocale(locale.LC_ALL, "");
_today = ""
_yesterday = ""
def init_date():
global _today, _yesterday
_today = time.strftime("%d %b %Y")
dt = datetime.timedelta(days=1)
_yesterday = time.strftime("%d %b %Y", (datetime.datetime.today() - dt).timetuple())
def format_date(row, full = False):
th_time = time.strptime(row, "%Y-%m-%d %H:%M:%S")
time_format = time.strftime("%d %b %Y", th_time)
if time_format == _today:
time_format = time.strftime("%H:%M", th_time)
elif time_format == _yesterday:
time_format = time.strftime("hier" + ", %H:%M", th_time)
elif full:
time_format = time.strftime("%a %d %b %Y %H:%M", th_time)
return time_format.decode("utf-8")