We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bbda351 commit a1953d4Copy full SHA for a1953d4
CountingMinutes.rb
@@ -0,0 +1,37 @@
1
+def CountingMinutesI(str)
2
+ ampm = str.scan(/[a-zA-Z]+/)
3
+ times = str.scan(/\d+/)
4
+ hour1 = times[0].to_i
5
+ minutes1 = times[1].to_i
6
+ hour2 = times[2].to_i
7
+ minutes2 = times[3].to_i
8
+
9
+ if ampm[0] == "pm"
10
+ hour1 = hour1 + 12
11
+ end
12
13
+ if ampm[0] == "am"
14
+ if hour1 == 12
15
+ hour1 == 0
16
17
18
19
+ if ampm[1] == "pm"
20
+ hour2 = hour2 + 12
21
22
23
+ if ampm[1] == "am"
24
+ if hour2 == 12
25
+ hour2 == 0
26
27
28
29
+ minutes1 = (60 * hour1) + minutes1
30
+ minutes2 = (60 * hour2) + minutes2
31
32
+ if minutes1 > minutes2
33
+ minutes2 = minutes2 + 24*60
34
35
+ return (minutes2 - minutes1).to_s
36
37
+end
0 commit comments