How many times will a bell tower ring? Introduction
A bell tower will ring its bells every hour, n times, with n being the the current hour on a 12 hour clock.
For example, a bell will ring 5 times at 5pm, and 10 times at 10am.
Task
Given two times in a suitable format, output the number of times the bell will ring, inclusive of the start and end times
Examples
&quot;10am-12pm&quot;
10+11+12= 33

[01:00, 05:00]
1+2+3+4+5 = 15

[11, 15]
11+12+1+2+3 = 29

[10:00pm, 10:00am]
10+11+12+1+2+3+4+5+6+7+8+9+10 = 88

If the start is the same as the end then the you simply just ouput the number of chimes for that hour:
[5pm, 5pm]
5 = 5

As you can see, you may choose an input method but the output must be an integer on its own (or an acceptable alternative) trailing/ leading newlines and spaces are allowed.
Note:

inputs may span from the afternoon of one day to the morning of the next.
the difference between the two times will never be more than 24 hours.
input is flexible so long as you clearly state what format your input is.
your input must have a clear distinction between AM and PM.
JavaScript (ES6), 38 35 bytes

f=(x,y)=&gt;~-x%12-~(x-y&amp;&amp;f(x%24+1,y))


Recursively adds the current number of bell rings to the total. Called like f(11,15); midnight is represented as 24. I got part of the ~- trick from @xnor's Python answer.

Test snippet



f=(x,y)=&gt;~-x%12-~(x-y&amp;&amp;f(x%24+1,y))
g=(x,y)=&gt;console.log("x:",x,"y:",y,"result:",f(x,y))

g(10,12)
g(1,5)
g(11,15)
g(22,10)
&lt;input id=A type="number" min=1 max=24 value=9&gt;
&lt;input id=B type="number" min=1 max=24 value=17&gt;
&lt;button onclick="g(A.value,B.value)"&gt;Run&lt;/button&gt;




Non-recursive version (Firefox 30+), 56 bytes

(x,y,t=0)=&gt;[for(_ of Array((y-x+25)%24))t+=x++%12||12]|t


Equivalent to the following ES6 function:

(x,y,t=0)=&gt;[...Array((y-x+25)%24))].map(_=&gt;t+=x++%12||12)|t