(a) Time served is deemed to begin on the day sentence is imposed, not on the day a prisoner is received by the Department of Corrections. It shall continue only during the time in which a prisoner is actually confined in a county jail or other local place of lawful confinement or while under the custody and supervision of the department.
(b) When the sentencing judge imposes sentence, he or she is to direct that the time already served by the defendant in jail or other place of detention is to be credited against the defendant.