-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_parser.py
More file actions
35 lines (33 loc) · 921 Bytes
/
Copy pathtest_parser.py
File metadata and controls
35 lines (33 loc) · 921 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
27
28
29
30
31
32
33
34
35
# Copy your function here
def parse_to_interval(raw_time):
if not raw_time: return None
clean = raw_time.upper().replace('AM', '').replace('PM', '').strip()
parts = clean.split(':')
try:
if len(parts) == 3:
h, m, s = parts
if int(h) >= 5:
return f"{h} minutes {m}.{s.replace('.', '')} seconds"
return f"{h} hours {m} minutes {s} seconds"
elif len(parts) == 2:
m, s = parts
return f"{m} minutes {s} seconds"
return clean
except:
return None
# Test cases from your actual data
test_data = [
"00:35:07.3",
"45:59",
"1:00:45",
"1:00:30.00",
"45:38.3",
"1:04:52.6",
"30:42:00",
"61:00:38 AM",
"53:34:00"
]
print(f"{'INPUT':<20} | {'OUTPUT (POSTGRES READY)':<30}")
print("-" * 55)
for item in test_data:
print(f"{item:<20} | {parse_to_interval(item):<30}")