“ART. 29. Period of preventive imprisonment deducted from term of imprisonment. – Offenders or accused who have undergone preventive imprisonment shall be credited in the service of their sentence consisting of deprivation of liberty, with the full time during which they have undergone preventive imprisonment if the detention prisoner agrees voluntarily in writing after being informed of the effects thereof and with the assistance of counsel to abide by the same disciplinary rules imposed upon convicted prisoners, except in the following cases:
“1. When they are recidivists, or have been convicted previously twice or more times of any crime; and
“2. When upon being summoned for the execution of their sentence they have failed to surrender voluntarily.
“If the detention prisoner does not agree to abide by the same disciplinary rules imposed upon convicted prisoners, he shall do so in writing with the assistance of a counsel and shall be credited in the service of his sentence with four-fifths of the time during which he has undergone preventive imprisonment.
“Credit for preventive imprisonment for the penalty of reclusion perpetua shall be deducted from thirty (30) years.
“Whenever an accused has undergone preventive imprisonment for a period equal to the possible maximum imprisonment of the offense charged to which he may be sentenced and his case is not yet terminated, he shall be released immediately without prejudice to the continuation of the trial thereof or the proceeding on appeal, if the same is under review. Computation of preventive imprisonment for purposes of immediate release under this paragraph shall be the actual period of detention with good conduct time allowance: Provided, however, That if the accused is absent without justifiable cause at any stage of the trial, the court may motu proprio order the rearrest of the accused: Provided, finally, That recidivists, habitual delinquents, escapees and persons charged with heinous crimes are excluded from the coverage of this Act. In case the maximum penalty to which the accused may be sentenced is lestierro, he shall be released after thirty (30) days of preventive imprisonment.”