Thank you for the question.
I believe you're referring to credit for pre-sentence custody for offenders who are held pretrial. This comes down to the principle of parity in sentencing, which holds that individuals who are similarly situated, who commit similar offences in similar circumstances, should be treated the same, or as similarly as possible, and so courts are permitted to take into account the time they spend in prison before their trial and sentencing so that the ultimate time behind bars comes out to be about the same.
The Criminal Code provides for a 1.5:1 ratio—
