-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.py
31 lines (25 loc) · 912 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
27
28
29
30
31
from datetime import datetime
def transform_cadence(cadence_interval, cadence_interval_count):
if cadence_interval == 'day':
days = int(cadence_interval_count)
if days % 30 == 0:
return 'month', days // 30
elif days % 7 == 0:
return 'week', days // 7
else:
return 'week', days // 7
elif cadence_interval == 'month':
return 'month', int(cadence_interval_count)
elif cadence_interval == 'week':
return 'week', int(cadence_interval_count)
else:
return cadence_interval, int(cadence_interval_count)
def extract_id_from_token(token):
try:
return token.split('/')[-1]
except IndexError:
return None
def format_iso8601(date_str):
date_obj = datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%S")
formatted_date = date_obj.strftime("%Y-%m-%dT%H:%M:%SZ")
return formatted_date