
90 Cal.App.3d 190 (1979)
153 Cal. Rptr. 317
In re MAURICE S., a Person Coming Under the Juvenile Court Law.
THE PEOPLE, Plaintiff and Respondent,
v.
MAURICE S., Defendant and Appellant.
Docket No. 45006.
Court of Appeals of California, First District, Division Four.
March 7, 1979.
*191 COUNSEL
Quin Denvir, State Public Defender, under appointment by the Court of Appeal, Clifton R. Jeffers, Chief Assistant State Public Defender, Philip A. Schnayerson and Dennis P. Riordan, Deputy State Public Defenders, for Defendant and Appellant.
*192 Evelle J. Younger, Attorney General, Jack R. Winkler, Chief Assistant Attorney General, Edward P. O'Brien, Assistant Attorney General, Timothy A. Reardon, William D. Stein, Robert R. Granucci and Herbert F. Wilkinson, Deputy Attorneys General, for Plaintiff and Respondent.
OPINION
CHRISTIAN, J.
Maurice S. appeals from a judgment of the juvenile court committing him to the Youth Authority upon findings that he was a person coming within the provisions of Welfare and Institutions Code section 602 in that he took personal property from the possession and immediate presence of a victim (Pen. Code, § 211) and that he escaped from the juvenile hall (Welf. & Inst. Code, § 871).
Appellant and several other boys blocked the passage of the victim's car by backing a car out into the street. When the victim's car stopped, it was surrounded by the boys. Appellant forced his way partly into the car and seized the victim's purse. Appellant was taken into custody within a few minutes and identified by the victim and other witnesses.
The allegation of escape from the juvenile hall was submitted on a stipulation that a custodial officer would testify that appellant "did escape from Cottage B3" on March 8.
Appellant points out, and the Attorney General has properly conceded, that the commitment to the Youth Authority issued by the court is erroneous in specifying consecutive terms of confinement. The findings and order actually set the period of confinement at not to exceed three years. The commitment must be amended to eliminate the error.
(1a) In a supplemental brief appellant contends that, under Penal Code section 2900.5, appellant is entitled to credit against his term of confinement for 37 days actually spent in custody and 18 days good time credit (see Pen. Code, § 4019; People v. Doganiere (1978) 86 Cal. App.3d 237 [150 Cal. Rptr. 61]; People v. Brown[*] (Cal. App.)). The theory is that it is a denial of equal protection to withhold from a juvenile offender the benefit of provisions which have the effect of shortening the actual period of confinement of adult offenders (see People v. Olivas (1976) 17 Cal.3d 236 [131 Cal. Rptr. 55, 551 P.2d 375]). The Attorney General resists this contention, citing In re Leonard R. (1977) 76 Cal. App.3d 100 [142 *193 Cal. Rptr. 632], where the Court of Appeal in the Second Appellate District distinguished Olivas on the basis that it involved a Youth Authority commitment issued in a proceeding in adult court. We are unable to accept the distinction drawn in In re Leonard R.
The minor's stated term of confinement at CYA is 36 months, the middle term for the principal offense. An adult convicted of a similar offense and similarly sentenced would also be confined for up to 36 months.
(2) Personal liberty is a constitutionally protected right (People v. Olivas, supra, 17 Cal.3d 236, 251). Classifications that deal with restraints on liberty are subject to the strict scrutiny test applicable to equal protection of fundamental interests (People v. Olivas, supra, at p. 251). That test is satisfied by a compelling state interest which demonstrates that the distinctions drawn by the statute are necessary to further that purpose (People v. Olivas, supra, at p. 251).
(3) Persons similarly situated with respect to the legitimate purpose of the law are entitled to like treatment (Purdy & Fitzpatrick v. State of California (1969) 71 Cal.2d 566, 578 [79 Cal. Rptr. 77, 456 P.2d 645, 38 A.L.R.3d 1194]). The question is whether the purpose of juvenile confinement can be distinguished from the purpose of adult confinement.
Under the determinate sentencing law the declared purpose of adult incarceration is punishment (Pen. Code, § 1170, subd. (a)(1)). The declared purposes of juvenile commitment are treatment and rehabilitation (In re Aline D. (1975) 14 Cal.3d 557, 567 [121 Cal. Rptr. 816, 536 P.2d 65]). An additional element was added to the purpose of the juvenile law in the 1976 amendment to the Welfare and Institutions Code (Stats. 1976, ch. 1068, § 1.5; Stats. 1976, ch. 1071, § 29; Stats. 1977, ch. 910, § 1) also "to protect the public from criminal conduct by minors." Placement in the CYA is a last resort after all other efforts permitted by the applicable provisions of the Welfare and Institutions Code have failed (In re Aline D., supra. at p. 564).
The Supreme Court noted in People v. Olivas, supra, 17 Cal.3d at pages 244-245, "Commitment in an institution of the Youth Authority can be described in many ways and can encompass a wide range of controls. However, the key factor common to all such descriptions is the physical restraint of the ward's person. While wards confined in institutions of the Youth Authority may often experience greater freedom within the *194 institution than individuals confined in state prisons or mental hospitals [citation], they are nevertheless incarcerated against their will, ..."
The Supreme Court treated punishment as the primary purpose for juvenile confinement when it rejected contentions that the difference in the potential duration of incarceration between youthful and adult offenders was justified by the supposed relative malleability of youthful offenders and the need for a longer period of confinement in order to achieve rehabilitation.
(1b) We conclude, on the authority of Olivas, that Youth Authority confinement of juveniles and Adult Authority confinement of adult prisoners share for the purposes of equal protection analysis a common purpose of punishment. No basis has been found for distinguishing between Youth Authority inmates and adult prisoners in regard to credit for time in confinement.
The judgment is modified by deleting the provision for consecutiveness; as modified the judgment is affirmed and the cause is remanded to the trial court with directions to compute appellant's credit time in accordance with the views herein expressed.
As so modified the judgment is affirmed.
Caldecott, P.J., and Delucchi, J.,[**] concurred.
On March 28, 1979, the judgment was modified to read as printed above. Respondent's petition for a hearing by the Supreme Court was denied May 30, 1979.
NOTES
[*]   Reporter's Note: Hearing granted. May 30, 1979 (Crim. 20998).
[**]   Assigned by the Chairperson of the Judicial Council.
