-- Tries to update the display according to the time (in minutes after midnight), else displays err

function TryUpdate(mins)
	local d_hrsTens, d_hrsOnes, d_minsTens, d_minsOnes, d_noon
	local c_hrs, c_mins
	if mins >= 0 and mins < 1440 then
		c_hrs = math.floor(mins/60)
		c_mins = mins%60
		
		if USE_MILITARY_TIME then
			d_hrsTens = displayMap[math.floor(c_hrs/10)+1]
			d_hrsOnes = displayMap[(c_hrs - (math.floor(c_hrs/10)*10))+1]
			
			-- Special case for 2400
			if c_hrs == 0 and c_mins == 0 then
				d_hrsTens = displayMap[3]
				d_hrsOnes = displayMap[5]
			end
		else
			d_hrsTens = displayMap[math.floor(((c_hrs)%12)/10)+1]
			d_hrsOnes = displayMap[(((c_hrs)%12) - (math.floor(((c_hrs)%12)/10)*10))+1]
			
			-- Special case for 12:00 A/P M
			if c_hrs%12 == 0 then
				d_hrsTens = displayMap[2]
				d_hrsOnes = displayMap[3]
			end
		end
		d_minsTens = displayMap[math.floor(c_mins/10)+1]
		d_minsOnes = displayMap[(c_mins - (math.floor(c_mins/10)*10))+1]
		d_noon = (mins >= 720) and noon_P or noon_A
		
		Display(d_hrsTens, d_hrsOnes, d_minsTens, d_minsOnes, d_noon)
	else
		Error()
	end
end
