def adjust_h(h, m, ap)

        if ap == 'midnight' && h == 12
          24
        elsif ap == 'pm' && h < 12 # post meridian
          h + 12
        elsif ap == 'am' && h == 12 # ante meridian
          0
        else
          h
        end
      end
Try to follow https://en.wikipedia.org/wiki/12-hour_clock#Confusion_at_noon_and_midnight