identification division.
program-id. lab6asub.
data
division.
working-storage section.
linkage
section.
01
current-time.
05
ct-hh pic 99.
05
ct-mm pic 99.
01 new-time.
05
mt-hh pic z9.
05 pic x value ":".
05
mt-mm pic 99.
05 pic x value space.
05
mt-ampm pic xx.
procedure
division using current-time new-time.
100-main.
move
ct-mm to mt-mm.
if ct-hh
= 0
move
12 to mt-hh
move
"AM" to mt-ampm
else if
ct-hh < 12
move
ct-hh to mt-hh
move
"AM" to mt-ampm
else if
ct-hh = 12
move
ct-hh to mt-hh
move
"PM" to mt-ampm
else
subtract 12 from ct-hh giving mt-hh
move
"PM" to mt-ampm
end-if.
exit
program.