(a) Notwithstanding any provision to the code to the contrary and in addition to any fine, cost assessment or fee authorized or required to be imposed upon a person by virtue of his or her conviction of a criminal provision of this code, or a lawfully enacted ordinance of a political subdivision of this state, a person so convicted and incarcerated in a regional jail by virtue of said conviction may be assessed the costs of up to thirty days of his or her incarceration.
(b) Prior to any person being required to pay the cost of his or her incarceration pursuant to the provisions of subsection (a) of this section, a hearing shall be held before the sentencing court to determine his or her ability to pay. The court may not sentence a defendant to pay his or her costs of incarceration unless he or she is or in the foreseeable future will be able to pay them. In determining the amount and method of payment of costs, the court shall take account of the financial resources of the defendant and the nature of the burden that payment of costs will impose.
(c) A defendant who has been sentenced to pay costs and who is not in willful default in the payment of the costs may at any time petition the sentencing court for remission of the payment of costs or of any unpaid portion of the costs. If it appears to the satisfaction of the court that payment of the amount due will impose manifest hardship on the defendant or the defendant's family or dependents, the court may excuse payment of all or part of the amount due in costs, or modify the method of payment.