-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
26 lines (24 loc) · 794 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 math
import calendar
import datetime
def round_half_up(n, decimals=2):
multiplier = 10 ** decimals
return math.floor(int(n)*multiplier + 0.5) / multiplier
def get_rbt_coordinator(db):
coordinator = db.users.find_one({'ProviderId': 1382528})
# print(coordinator)
if coordinator:
return coordinator['name']
else:
return "1382528"
def get_second_monday(year, month):
c = calendar.Calendar(firstweekday=calendar.MONDAY)
if month < 12:
monthcal = c.monthdatescalendar(year, month+1)
else:
monthcal = c.monthdatescalendar(year+1, 1)
d = monthcal[1][0].day
if d > 7:
return datetime.datetime.strftime(monthcal[1][0], "%m/%d/%Y")
else:
return datetime.datetime.strftime(monthcal[2][0], "%m/%d/%Y")