
40 Cal.App.3d 578 (1974)
115 Cal. Rptr. 160
THE PEOPLE, Plaintiff and Respondent,
v.
CHRISTOPHER BRIAN COWSAR, Defendant and Appellant.
Docket No. 12283.
Court of Appeals of California, First District, Division Three.
July 10, 1974.
*579 COUNSEL
James C. Hooley, Public Defender, and Michael G. Millman, Assistant Public Defender, for Defendant and Appellant.
Evelle J. Younger, Attorney General, Jack R. Winkler, Chief Assistant Attorney General, Edward P. O'Brien, Assistant Attorney General, Gloria DeHart and Ina Gyemant, Deputy Attorneys General, for Plaintiff and Respondent.
OPINION
BROWN (H.C.), J.
Appellant was charged with murder (Pen. Code, § 187) on May 18, 1971. The criminal proceedings were suspended on June 17, 1971, on the court's own motion and proceedings under Penal Code section 1368 were instituted for a determination of appellant's sanity. On November 1, 1971, the court found appellant to be insane and committed him to the Atascadero State Hospital. On April 18, 1973, the court found that appellant had regained his sanity. Thereafter, appellant pled guilty to murder of the second degree. From the time appellant was arrested until the time he was sentenced, he spent approximately two years in custody. He received credit of 273 days for the period of pretrial custody. (1) The sole contention on this appeal is that the court erred in not crediting on his sentence the time he spent at Atascadero. Appellant argues that to fail to construe Penal Code section 2900.5 to include this time would be a denial of equal protection and a violation of the prohibition against double jeopardy. We agree that he should receive credit for the time spent in the state hospital.
Section 2900.5, added to the Penal Code in 1971, provides for a mandatory credit to his sentence of all time spent by a defendant "in custody in any city, county, or city and county jail." The question of *580 whether a defendant must also be credited with time spent in a hospital upon a finding of insanity pursuant to Penal Code section 1368 has not been considered in California. The question, or one closely related, has been considered, however, in other jurisdictions and resolved in favor of the defendant. (See, e.g., People v. Noble (1961) 28 Misc.2d 646 [216 N.Y.S.2d 541]; State v. Ewell (1964) 234 Md. 56 [198 A.2d 275, 277]; In re Stearns' Petition (1961) 343 Mass. 53 [175 N.E.2d 470, 472]; Sawyer v. Clark (1967) 386 F.2d 633 [128 App.D.C. 206]; Cephus v. United States (1967) 389 F.2d 317 [128 App.D.C. 366].)
In People v. Noble, supra, the statute under consideration by the New York Supreme Court provided for crediting of pre-sentence time spent "in a prison or jail." The People contended, as they do here, that the statute did not extend to time spent in a hospital for the criminally insane. The court did not agree with this narrow construction and noted that had the defendant's illness been physical rather than mental he would have been automatically credited with the time spent in the criminal wards of a hospital. "To deny him the same benefits because of a claimed mental deficiency would be reading into the law recently enacted an unreasonable and unintended distinction." (At p. 542.)
Appellant argues that the distinctions which would result from a narrow interpretation of section 2900.5 would amount to a denial of equal protection. Disparity in treatment arising from distinctions in crediting time has been held unconstitutional where there is no rational basis for the classification made. (See In re Bennett (1969) 71 Cal.2d 117, 120 [77 Cal. Rptr. 457, 454 P.2d 33]; In re Young (1973) 32 Cal. App.3d 68, 72-73 [107 Cal. Rptr. 915]; Stapf v. United States (1966) 367 F.2d 326, 329 [125 App.D.C. 100].)
Respondent offers no rationale for distinguishing between a person held in custody in a jail and in a state hospital. Respondent merely points to the fact that custody of a person found insane before trial is a civil commitment. The relevance of this fact to a state purpose in crediting or not crediting the time in custody is not explained. The purpose of both punishment and treatment of criminal offenders has been described as "`directed toward one or more of three ends: (1) to discourage and act as a deterrent upon future criminal activity, (2) to confine the offender so that he may not harm society and (3) to correct and rehabilitate the offender. There is no place in the scheme for punishment for its own sake, the product simply of vengeance or retribution.'" (In re Estrada (1965) 63 Cal.2d 740, 745 [48 Cal. Rptr. 172, 408 P.2d 948].) The time *581 spent involuntarily confined at Atascadero served all of the permissible purposes of punishment and cannot be distinguished from jail time for sentencing purposes.
If appellant had become insane after trial rather than before, he would have received credit for time spent recovering in a state hospital. (Pen. Code, § 2684.) Again, no rationale is offered for the disparity in treatment between defendants on the basis of the time of their mental illness, an event out of the control of the defendant. The Supreme Court held in In re Bennett, supra, 71 Cal.2d 117, 120, that the Adult Authority erred in denying a parolee credit for time he spent at Atascadero pursuant to commitment orders of the superior court made when petitioner was arrested for new offenses and was found presently insane. The Supreme Court viewed his commitment as a return to custody under Penal Code section 3064, not finding any rational basis for distinguishing between the prisoner committed to a state hospital by court order and one transferred there by the Director of Corrections. A similar distinction, and one equally lacking in reasonableness, would result here if section 2900.5 were interpreted to deny appellant this credit.
We have concluded that section 2900.5 of the Penal Code should be interpreted to avoid an unconstitutional disparity in treatment between those confined in jail and in a state hospital prior to trial.
The matter is remanded to the trial court with directions to give credit to appellant for the time he was hospitalized at the Atascadero State Hospital.
Draper, P.J., and Devine, J.,[*] concurred.
NOTES
[*]   Retired Presiding Justice of the Court of Appeal sitting under assignment by the Chairman of the Judicial Council.
