s = io.read() hour, min, pm, utc = string.match(s, "(%d+) (%d+) UTC([%+%-])([%.%d]+)") hour, min = tonumber(hour), tonumber(min) utc_h, utc_m = string.match(utc, "(%d+)%.?(%d?)") if(utc_m == "") then utc_m = "0" end utc_h, utc_m = tonumber(utc_h), tonumber(utc_m) if(pm == "-") then utc_h, utc_m = -utc_h, -utc_m end v = (hour + utc_h - 9) * 60 + utc_m * 6 + min v = v % 1440 print(string.format("%02d:%02d", math.floor(v / 60), v % 60))