a_h1 = 0
a_h2 = 0
a_m1 = 0
a_m2 = 0
t_h1 = 0
t_h2 = 0
t_m1 = 0
t_m2 = 0
H1 = 0
H2 = 0
M1 = 0
M2 = 0
selector = 1
while true do
 screen:clear()
 pad = Controls.read()
 Android:Barre()
 H1 = string.sub(string.reverse(H),-1)
 H2 = string.sub(H,-1)
 M1 = string.sub(string.reverse(M),-1)
 M2 = string.sub(M,-1)
 if t_H1 == H1 and t_H2 == H2 and t_M1 == M1 and t_M2 == M2 then
  screen:fillRect(1,60,7,9,Color.new(0,0,255))
 end
 if System.getTime(5) == "pm" and System.getTime(1) ~= "12" then
  H = System.getTime(1) + 12
 else
  H = System.getTime(1)
 end
 if System.getTime(2) < 10 then
  M = "0"..System.getTime(2)
 else
  M = System.getTime(2)
 end
 screen:print(20,50,H1..H2..":"..M1..M2.." Alarme:",Color.new(255,255,255))
 screen:fillRect(11+selector*8,60,7,9,Color.new(255,0,0))
 screen:fillRect(11+selector*8,60,7,8,Color.new(100,100,100))
 screen:print(20,60,t_h1..t_h2..":"..t_m1..t_m2,Color.new(255,255,255))
 if pad:right() and not oldpad:right() and selector<5 then
  selector=selector+1
 end
 if pad:left() and not oldpad:left() and selector>1 then
  selector=selector-1
 end
 if pad:up() and not oldpad:up() then
  if selector == 1 and a_h1 < 2 then
   a_h1 = a_h1 + 1
  end
  if selector == 2 and a_h2 < 9 then
   a_h2 = a_h2 + 1
  end
  if selector == 4 and a_m1 < 6 then
   a_m1 = a_m1 + 1
  end
  if selector == 5 and a_m2 < 9 then
   a_m2 = a_m2 + 1
  end
 end
 if pad:down() and not oldpad:dowm() then
  if selector == 1 and a_h1 > 1 then
   a_h1 = a_h1 - 1
  end
  if selector == 2 and a_h2 > 1 then
   a_h2 = a_h2 - 1
  end
  if selector == 4 and a_m1 > 1 then
   a_m1 = a_m1 - 1
  end
  if selector == 5 and a_m2 > 1 then
   a_m2 = a_m2 - 1
  end
 end
 t_h1 = ""..a_h1..""
 t_h2 = ""..a_h2..""
 t_m1 = ""..a_m1..""
 t_m2 = ""..a_m2..""
 if pad:cross() then
  Android:Quitter()
 end
 oldpad = pad
 screen.flip()
 screen.waitVblankStart()
end
