
80 Cal.App.3d 407 (1978)
145 Cal. Rptr. 711
THE PEOPLE, Petitioner,
v.
THE SUPERIOR COURT OF LOS ANGELES COUNTY, Respondent; LEON EARL RIGG, Real Party in Interest. THE PEOPLE, Petitioner,
v.
THE SUPERIOR COURT OF LOS ANGELES COUNTY, Respondent; CARL R. ARMSTRONG, Real Party in Interest. THE PEOPLE, Petitioner,
v.
THE SUPERIOR COURT OF LOS ANGELES COUNTY, Respondent; MARK CHARLES BRANDES, Real Party in Interest. THE PEOPLE, Petitioner,
v.
THE SUPERIOR COURT OF LOS ANGELES COUNTY, Respondent; JOSEPH CARLOS POGGI, Real Party in Interest.
Docket Nos. 52144, 52275, 52276, 52454.
Court of Appeals of California, Second District, Division Four.
April 26, 1978.
*410 COUNSEL
Evelle J. Younger, Attorney General, Jack R. Winkler, Chief Assistant Attorney General, S. Clark Moore, Assistant Attorney General, Edward T. Fogel, Jr., Shunji Asari, Joyce L. Kennard, John A. Saurenman and Robert D. Breton, Deputy Attorneys General, for Petitioner.
No appearance for Respondent.
Wilbur F. Littlefield, Public Defender, Dennis A. Fischer, Seymour Applebaum and Anita S. Brenner, Deputy Public Defenders, for Real Parties in Interest.
OPINION
KINGSLEY, J.
We have consolidated these four cases for hearing and decision because they involve the common issue of the interpretation and application of sections 6316.1 and 6316.2 of the Welfare and Institutions Code, added by the Legislature in 1977 by chapter 164 of the Statutes of 1977.
*411 The portions of those sections pertinent to these proceedings read as follows:
Section 6316.1:
"(a) In the case of any person found to be a mentally disordered sex offender who committed a felony on or after July 1, 1977, the court shall state in the commitment order the maximum term of commitment, and the person may not be kept in actual custody longer than the maximum term of commitment, except as provided in Section 6316.2. For the purposes of this section `maximum term of commitment' shall mean the longest term of imprisonment which could have been imposed for the offense or offenses of which the defendant was convicted, including the upper term of the base offense and any additional terms for enhancements and consecutive sentences which could have been imposed less any applicable credits as defined by Section 2900.5 of the Penal Code and disregarding any credits which could have been earned under Section 2930 to 2932, inclusive, of the Penal Code.
"(b) In the case of a person found to be a mentally disordered sex offender who committed a felony prior to July 1, 1977, who could have been sentenced under Section 1168 or 1170 of the Penal Code if the offense were committed after July 1, 1977, the Community Release Board shall determine the maximum term of commitment which could have been imposed under subdivision (a), and the person may not be kept in actual custody longer than the maximum term of commitment, except as provided in Section 6316.2.
"In fixing a term under this section, the board shall utilize the upper term of imprisonment which could have been imposed for the offense or offenses of which the defendant was convicted, increased by any additional terms which could have been imposed based on matters which were found to be true in the committing court. However, if at least two of the members of the board after reviewing the person's file determine that a longer term should be imposed for the reasons specified in Section 1170.2 of the Penal Code, a longer term may be imposed following the procedures and guidelines set forth in Section 1170.2 of the Penal Code, except that any hearings deemed necessary by the board shall be held before April 1, 1978. Within 90 days of July 1, 1977, or of the date the person is received by the State Department of Health, whichever is later, the Community Release Board shall provide each person committed pursuant to Section 6316 with the determination of his maximum term of *412 commitment or shall notify such person that he will be scheduled for a hearing to determine his term."
Section 6316.2:
"(a) A person may be committed beyond the term prescribed by Section 6316.1 only under the procedure set forth in this section and only if such person meets all of the following:
"(1) The `sex offense' as defined in subdivision (a) of Section 6302 of which the person has been convicted is a felony, whether committed before or after July 1, 1977, or is a misdemeanor which was committed before July 1, 1977.
"(2) Suffers from a mental disorder, and as a result of such mental disorder, is predisposed to the commission of sexual offenses to such a degree that he presents a serious threat of substantial harm to the health and safety of others.
"(b) If during a commitment under this part, the Director of Health has good cause to believe that a patient is a person described in subdivision (a), the director may submit such supporting evaluations and case file to the prosecuting attorney who may file a petition for extended commitment in the superior court which issued the original commitment. Such petition shall be filed no later than 90 days before the expiration of the original commitment. Such petition shall state the reasons for the extended commitment, with accompanying affidavits specifying the factual basis for believing that the person meets each of the requirements set forth in subdivision (a).
"(c) At the time of filing a petition, the court shall advise the patient named in the petition of his right to be represented by an attorney and of his right to a jury trial. The rules of discovery in criminal cases shall apply.
"(d) The court shall conduct a hearing on the petition for extended commitment. The trial shall be by jury unless waived by both the patient and the prosecuting attorney. The trial shall commence no later than 30 days prior to the time the patient would otherwise have been released by the State Department of Health.
*413 "(e) The patient shall be entitled to the rights guaranteed under the Federal and State Constitutions for criminal proceedings. All proceedings shall be in accordance with applicable constitutional guarantees. Pursuant to Sections 4700, 4700.1, and 4700.2 of the Penal Code, the state shall bear all expenses of transportation, care and custody of the patient and all trial and related costs, and shall be represented by the Attorney General or the district attorney with the consent of the Attorney General. If the patient is indigent, the State Public Defender shall be appointed. The State Public Defender may provide for representation of the patient in any manner authorized by Section 15402 of the Government Code. Appointment of necessary psychologists or psychiatrists shall be made in accordance with this article and Penal Code and Evidence Code provisions applicable to criminal defendants who have entered pleas of not guilty by reason of insanity or asserted diminished capacity defenses.
"(f) If the court or jury finds that the patient is a person described in subdivision (a), the court may order the patient committed to the State Department of Health in a treatment facility. A commitment or a recommitment under Section 6316.1 shall be for a period of one year from the date of termination of the previous commitment.
"(g) A person committed under this section to the State Department of Health shall be eligible for outpatient release as provided in this article.
"(h) Prior to termination of a commitment under this section, a petition for recommitment may be filed to determine whether the person remains a person described in subdivision (a). Such recommitment proceeding shall be conducted in accordance with the provisions of this article.
"(i) Any commitment to the State Department of Health under this article places an affirmative obligation on the department to provide treatment for the underlying causes of the person's mental disorder.
"This section shall remain in effect only until January 1, 1979, and on such date is repealed."
All four of the real parties in interest were convicted of felonies prior to July 1, 1977, and, prior to that date, had been committed as mentally disordered sex offenders (MDSOs) for indeterminate terms. Using the formula prescribed by section 6316.1, the Community Release Board determined the "maximum term" of three of them (Rigg, Armstrong *414 and Brandes) as being a term expiring prior to July 1, 1977; in the case of Poggi, acting on August 30, 1977 (within the 90-day period allowed by § 6316.1) the board fixed his "maximum term" as expiring on November 14, 1977. Section 6416.1 expressly provided that the so-called "maximum term" is subject to extension under the circumstances defined in section 6316.2. The People filed petitions for an extended commitment of each of the real parties in interest. The Rigg petition (case No. A603635) was filed on October 12, 1977; the Armstrong petition (case No. A249785) was filed on October 12, 1977; the Brandes petition (case No. A127058) was filed on October 21, 1977; the Poggi petition (case No. A431512) was filed on October 21, 1977. In all four cases the trial court sustained demurrers to the petitions on the ground that they had been filed too late, dismissed the petitions, and ordered the real parties in interest released. The People here seek writs to vacate those orders; we order writs of mandate to issue as prayed.

I
(1) In their returns to our alternative writs, the real parties in interest seek to sustain the orders on an additional ground. They contend that the provision in section 6316.2 which authorizes extended MDSO commitments deprives them of equal protection of the law, since persons convicted of the same crimes but sentenced to state prison rather than committed as MDSOs are not subject to a similar extension.
To state the contention is to answer it. Implicit in the decision to commit to state prison rather than as an MDSO is a finding that that defendant does not need the specialized psychiatric treatment involved in the MDSO process but that society will be amply protected by the statutory prison term, whereas the MDSOs are committed because they have been found to need the specialized process. The difference in the mental condition of the two classes is an adequate constitutional ground for the difference herein involved.

II
(2a) The trial court acted on the theory that subdivision (b) of section 6316.2 purports to require the filing of a petition for "extended commitment" more than 90 days prior to the expiration of the "maximum term" as set by the Community Release Board under section 6316.1. As the dates involved in the four cases before us show, it was impossible for the People to have filed their petitions at a time ninety *415 days before the dates so set. In three of the cases, the date, computed under section 6316.1, had already arrived before section 6316.2 came into force on July 1, 1977; in the fourth, only eighty days intervened between the date the board's computation was announced and the date so set.
(3a) However, we conclude that that theory raises a false issue. The language herein involved is as follows: "Such petition shall be filed no later than 90 days before the expiration of the original commitment." (Italics added.) In all the four cases the original commitment, under the law in force when the real parties were first committed by the courts to the MDSO program, was for an indefinite term. That term had not expired either when the statutes herein involved came into force or when the Community Release Board acted. It follows that, in the case of pre-1977 committees, the quoted language simply was not applicable, since it is impossible to determine when a date 90 days prior to the expiration of an indeterminate commitment will arrive. The result is that, although the provision in section 6316.2 for "extended commitments" is applicable to the four persons herein involved, the Legislature has set no date for the filing of petitions for that result.
(4) Real parties in interest also point to subdivision (d) of section 6316.2, which entitles the committee to a jury trial on the petition for extended commitment which trial "shall commence no later than 30 days prior to the time the patient would otherwise have been released by the State Department of Health."
For a person who has committed a felony after July 1, 1977, the application of that language is clear: the jury trial must be heard at least 30 days before the expiration of the "maximum term" fixed under section 6316.1. For a person whose "maximum term" is fixed to expire a substantial time after July 1, 1977, subdivision (d) has the same application. But for persons, such as the four involved in these cases, whose "maximum terms" produce expiration dates prior to or immediately after the effective date of the new law, the thirty-day time limit cannot be given that literal application. It cannot be assumed that the Legislature intended such persons to be denied a jury trial, or that the director be denied a hearing on the petition which subdivision (b) authorizes the director to file. The 30-day time limit is doubtless a part of the time plan which starts with the 90-day filing limitation. The phrase "the time when the patient would otherwise have been released" can refer only to those persons whose "maximum terms" are to expire at a *416 time when the director may file his petition more than 90 days before that expiration date.
(3b) Considerations of due process do require that petitions for extended commitments should be filed without unreasonable delay after the Community Release Board has finally determined that the "maximum term" will provide an expiration date prior to or soon after the effective date of the new statute. (2b) We conclude that that standard was met in the four cases before us.
In Rigg, the board finalized its action on September 26, 1977; the petition was filed the following day. In Armstrong, the board acted on September 26th; the petition was filed on October 12th. In Brandes, the board acted on September 26th; the petition was filed on October 13th. In Poggi, the board acted on August 30th; the petition was filed on October 21st.[1] Absent some showing in the court below when the petitions are heard that those brief delays (none over six weeks) actually worked to the prejudice of the committees, we conclude that, on the record now before us, the director acted with commendable speed.
Let peremptory writs of mandate issue in the four cases before us, directing the superior court to act as follows:
(1) In superior court case No. A603365, to vacate its order of September 30, 1977; (2) in superior court case No. A249785, to vacate its order of October 19, 1977; (3) in superior court case No. A127058, to vacate its order of October 19, 1977; (4) in superior court case No. A431512, to vacate its order of November 22, 1977; and to enter, in each of said cases, an order overruling the demurrer, recalling and cancelling the writs of habeas corpus entered in each of said cases on such dates, and to proceed to determine on their merits the petitions filed by the People in each of said cases.
Files, P.J., and Jefferson (Bernard), J., concurred.
The petition of the real parties in interest for a hearing by the Supreme Court was denied June 22, 1978.
NOTES
[1]  Preliminary findings had been made a short time earlier in each case, but the dates were not formally adopted until the dates set forth in the text.
