My question involves criminal law for the state of: Iowa

I was arrested and charged with possession of marijuana (5.9 grams) and opium (1.9 grams). I was booked into the county jail and was in a holding cell for 22 hours before i saw the magistrate and was then placed into general population for 17.5 hours until i was bonded out.I have already attended all my court dates.i got deferred judgement on the opium charge and was sentenced to 31 hours in jail.Why did they only give me 17.5 hours credit for time served? did that almost whole day in a holding cell count for nothing?! and also when i go in to serve the 31 hours do you think they will keep me the whole time? it's not a real crowded jail but i hear that jails would rather let you out early on a really short sentence because it saves them money.can anyone help me clear any of this up? it would be much appreciated. i have no prior criminal record but for all of this i got 31 hours in jail,fines, license revoked for 6 months, and will be starting probation upon release from jail.oh yeah and i have no prior criminal record.thanks for the help!