-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutil.py
More file actions
23 lines (21 loc) · 783 Bytes
/
util.py
File metadata and controls
23 lines (21 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/python
# -*- coding: utf-8 -*-
# encoding: utf-8
import datetime
import time
def get_duration_sec(startTimeStr,endTimeStr,time_format = '%Y-%m-%dT%H:%M:%S+08:00'):
start_tt = time.strptime(startTimeStr, time_format)
start_tick = int(time.mktime(start_tt))
end_tt = time.strptime(endTimeStr, time_format)
end_tick = int(time.mktime(end_tt))
last_sec = (end_tick - start_tick)
return last_sec
def getWeekStartAndEnd():
today = datetime.date.today()
print("today:",today)
week_start = today - datetime.timedelta(days=today.weekday())
print("week_start:",week_start)
work_day = 7
week_end = week_start + datetime.timedelta(days=work_day - 1)
print("week_end:",week_end)
return week_start,week_end