Whenever any person is committed to prison for nonpayment of any fine or costs, or both, he shall be credited with five dollars a day in reduction of the fine. When the person has remained imprisoned a sufficient length of time to extinguish the fine or costs, or both, computed at this rate, the officer having the prisoner in custody shall discharge him from custody under commitment. (Prior code § 5-2-16)