
19 Cal.3d 54 (1977)
560 P.2d 375
136 Cal. Rptr. 708
In re BRUCE DEWING on Habeas Corpus. In re MAX TELLEZ on Habeas Corpus.
Docket Nos. Crim. 19695, 19696.
Supreme Court of California.
March 4, 1977.
*56 COUNSEL
W. Thomas Jennings and Guy Peto for Petitioners.
Evelle J. Younger, Attorney General, Jack R. Winkler, Chief Assistant Attorney General, Arnold O. Overoye, Assistant Attorney General, Willard F. Jones and Edmund D. McMurray, Deputy Attorneys General, for Respondent.
OPINION
MOSK, J.
In these consolidated proceedings for writs of habeas corpus we are called upon to determine whether recent legislation extending the maximum discharge date from Youth Authority custody can constitutionally be applied to persons committed to such custody prior to its enactment. (Stats. 1976, ch. 1070, § 7.)
On June 20, 1974, petitioner Dewing was committed to the Youth Authority after conviction of assault with a deadly weapon in violation of Penal Code section 245, subdivision (a); on January 20, 1975, petitioner Tellez was likewise committed to the Youth Authority after conviction of the same offense. A violation of section 245, subdivision (a), is punishable in the discretion of the court as a felony or a misdemeanor. At the time of petitioners' respective convictions and commitments, Penal Code section 17, subdivision (b)(2), provided that when a crime is punishable as a felony or a misdemeanor, it is a misdemeanor for all purposes "When the court commits the defendant to the Youth Authority." (Stats. 1969, ch. 1144, § 1, p. 2214.) The Youth Authority Act provides that every person "convicted of a misdemeanor" and committed to the authority shall be discharged after two years or when he reaches his 23d birthday, whichever occurs later. (Welf. & Inst. Code, § 1770.)[1] It follows that as of the date of their convictions and commitments, petitioners were entitled to be discharged from Youth Authority custody no later than their 23d birthdays  i.e., on December 31, 1976, in the case of petitioner Dewing, and on March 28, 1977, in the case of petitioner Tellez.
*57 (1a) However, on September 20, 1976, emergency legislation took effect which amended Penal Code section 17. (Stats. 1976, ch. 1070, § 1.) Subdivision (b)(2) of the new statute provides that when a crime is punishable as a felony or a misdemeanor, it is a misdemeanor for all purposes "When the court, upon committing the defendant to the Youth Authority, designates the offense to be a misdemeanor." (Italics added.) The corollary, of course, is that if the court does not make that designation at the time of commitment, the offense will be deemed a felony during the period in which the defendant is in custody of the Youth Authority.[2] The Youth Authority Act provides that every person "convicted of a felony" and committed to the authority shall be discharged when he reaches his 25th birthday. (Welf. & Inst. Code, § 1771.) Accordingly, if petitioners had been convicted and committed without such a misdemeanor designation after September 20, 1976, they could have been held in custody for an additional two years following their 23d birthdays.
But the new statute purports to reach these petitioners even though they were convicted and committed before it took effect. Section 7 of the legislation (Stats. 1976, ch. 1070) declares that the amendments to Penal Code section 17 discussed herein apply to "all persons who may be or presently are" under Youth Authority jurisdiction by reason of a commitment following conviction of crime. (Italics added.) Petitioners contend the emphasized language is constitutionally invalid because it causes the new statute to operate as an ex post facto law as to them and all persons similarly situated. The point is well taken.
(2) Ex post facto laws are prohibited by both the federal and state Constitutions. (U.S. Const., art. I, § 9, cl. 3; Cal. Const., art. I, § 9.) It is settled that among such laws are those which retroactively modify the time of discharge from custody to the substantial detriment of the defendant, thereby in effect increasing the punishment previously imposed for his crime. (See, e.g., Lindsey v. Washington (1937) 301 U.S. 397, 400-402 [81 L.Ed. 1182, 1185, 1186, 57 S.Ct. 797]; In re Griffin (1965) 63 Cal.2d 757, 759-760 [48 Cal. Rptr. 183, 408 P.2d 959]; In re Lee (1918) 177 Cal. 690, 695-696 [171 P. 958].) (1b) The statutory language here in issue extends by two years the maximum period during which persons committed prior to its enactment may be held in the custody of the Youth Authority. As the Attorney General concedes, it therefore violates *58 the constitutional sanction against ex post facto laws. (In re Valenzuela (1969) 275 Cal. App.2d 483, 486-487 [79 Cal. Rptr. 760] [legislation authorizing extended detention of "physically dangerous" persons (see fn. 1, ante) held ex post facto as to petitioner theretofore committed to Youth Authority].)
Subsequently to filing the returns herein, the Attorney General advised this court by letter that petitioner Dewing was discharged from custody on January 3, 1977. His petition is therefore moot.
As noted above, petitioner Tellez will not be 23 years of age until March 28, 1977. He does not claim he is entitled to discharge prior to that date; and for the reasons stated herein, he cannot constitutionally be held thereafter under the authority of Welfare and Institutions Code section 1771.
The orders to show cause, having served their purpose, are discharged. The petitions for writs of habeas corpus are denied.
Tobriner, Acting C.J., Clark, J., Richardson, J., Sullivan, J.,[*] and Wright, J.,[] concurred.
NOTES
[1]  The statute also authorizes an extended detention of "physically dangerous" persons as defined in section 1800 of the same code (see In re Gary W. (1971) 5 Cal.3d 296 [96 Cal. Rptr. 1, 486 P.2d 1201]), but these provisions are not here in issue.
[2]  Another amendment to section 17  new subdivision (c)  declares that upon the discharge of such a defendant from the Youth Authority the offense shall "thereafter" be deemed a misdemeanor.
[*]   Retired Associate Justice of the Supreme Court sitting under assignment by the Chairman of the Judicial Council.
[]   Retired Chief Justice of California sitting under assignment by the Acting Chairman of the Judicial Council.
