
228 Cal.App.3d 1292 (1991)
279 Cal. Rptr. 494
THE PEOPLE, Plaintiff and Respondent,
v.
ALLAN ROY GUNDERSON, Defendant and Appellant.
Docket No. B043353.
Court of Appeals of California, Second District, Division Six.
March 27, 1991.
*1294 COUNSEL
Paul M. Posner, under appointment by the Court of Appeal, for Defendant and Appellant.
John K. Van de Kamp, Attorney General, Richard B. Iglehart, Chief Assistant Attorney General, Edward T. Fogel, Jr., Assistant Attorney General, Robert R. Anderson and David F. Glassman, Deputy Attorneys General, for Plaintiff and Respondent.
OPINION
GILBERT, J.
Here we hold that the time period for an extended commitment of a mentally disordered sex offender (MDSO) under Welfare and Institutions Code[1] section 6316.2 includes both inpatient and outpatient status.
(1) (See fn. 2.) Allan Roy Gunderson was committed as an MDSO in 1980 pursuant to section 6300 et seq.[2] He appeals an order revoking his outpatient status. We find his commitment has terminated, and reverse.


*1295 FACTS
In November of 1979, pursuant to a negotiated plea, Gunderson pleaded guilty to a violation of Penal Code section 288 in Marin County Superior Court. In January of 1980 the court committed Gunderson to Atascadero State Hospital as an MDSO for a period not to exceed seven years, the maximum term for which he could have been committed to state prison. With 94 days custody credit, the original commitment would end on October 2, 1986.
On April 18, 1986, the People filed a petition in Marin County to extend the MDSO commitment for two years to October 2, 1988. (§ 6316.2.) The court granted the extension, but allowed Gunderson to be treated as an outpatient. Gunderson was placed on outpatient status in November of 1986 but was not actually released as an outpatient until December 11, 1986. In February of 1988, Gunderson stipulated to the extension of his outpatient status through October 2, 1988. The stipulation was in writing and Gunderson waived his right to be present in court as well as his right to a hearing.
On September 22, 1988, the prosecutor and Gunderson's counsel stipulated "that defendant's outpatient status may be extended for 1 yr., to 10/2/89." The stipulation was made in the Marin Superior Court, Gunderson was not present and no waivers appear of record. Nor does there appear of record any petition to extend the MDSO commitment beyond October 2, 1988.
On March 20, 1989, San Luis Obispo County Mental Health Services requested by a letter to the superior court that Gunderson's outpatient status be revoked so that he could receive inpatient treatment. (Pen. Code, § 1608.) A supplemental letter requested that the revocation hearing be held in San Luis Obispo County for the convenience of witnesses.
Gunderson filed a petition for a writ of habeas corpus in the San Luis Obispo Superior Court. At the hearing on the petition Gunderson contended that the court had no jurisdiction because his MDSO commitment had expired on October 2, 1988, and had not been extended by his stipulation of September 22 to continue as an outpatient. The court sent the matter to the Marin Superior Court to determine the question of jurisdiction. The Marin court determined it still had jurisdiction and ordered the matter back to San Luis Obispo for the outpatient revocation hearing.
At the hearing the evidence showed that on three occasions Gunderson violated his outpatient treatment agreement by having contact with minors *1296 without the supervision of another adult. Gunderson was given a warning letter after the first incident. A psychologist testified that Gunderson did not appreciate the significance of the unauthorized contact with the children and had a lackadaisical attitude toward relapse prevention.
The court found by a preponderance of the evidence that Gunderson is a danger to the health and safety of others and requires further inpatient treatment.

DISCUSSION

I
Section 6316.1, subdivision (a) provides that a person committed as an MDSO "may not be kept in actual custody longer than the ... longest term of imprisonment which could have been imposed for the offense or offenses of which the defendant was convicted" except as provided in section 6316.2.
Section 6316.2 provides a procedure for extending the commitment beyond the maximum term if the sex offense was a misdemeanor committed before July 1, 1977, or a felony, and if the patient is predisposed to commit sexual offenses such that he presents a substantial danger of bodily harm to others. (§ 6316.2, subd. (a).)
A petition for extending the commitment must be filed no later than 90 days prior to the expiration of the original commitment and must state reasons with accompanying affidavits specifying the factual basis. (§ 6316.2, subd. (b).) A petition for recommitment may be filed prior to the termination of the extended commitment. (§ 6316.2, subd. (h).) The commitment or recommitment is for two years from the date of the termination of the previous commitment. (§ 6316.2, subd. (f).)
The trial must be by jury unless waived by both the patient and the prosecuting attorney (§ 6316.2, subd. (d)) and "[t]he patient shall be entitled to the rights guaranteed under the Federal and State Constitutions for criminal proceedings." (§ 6316.2, subd. (e).)
(2) In response to Gunderson's argument that his MDSO commitment was not extended beyond October 2, 1988, the People contend that it was not necessary to extend it. They cite In re Moye (1978) 22 Cal.3d 457, 464 [149 Cal. Rptr. 491, 584 P.2d 1097] for the proposition that the granting of outpatient status tolls the time of an MDSO commitment. The commitment was extended under section 6316.2 from October 2, 1986 to October 2, *1297 1988, but because Gunderson was released on outpatient status in December of 1986, he spent only two of the twenty-four months of his extended commitment in actual custody. The unstated conclusion the People would have us reach is that Gunderson remains committed without the necessity for further proceedings until he serves the remaining 22 months of his extended term in actual custody.
The People read Moye too broadly. There, the court stated only that, "... the term `actual custody' in section 6316.1 does not include any periods of outpatient supervision in determining the maximum period of confinement." (In re Moye, supra, 22 Cal.3d at p. 464.) Here, however, we are not concerned with determining the maximum period of confinement under section 6316.1; instead, the question is whether periods spent in outpatient supervision are included in calculating the two-year period of extended commitment under section 6316.2.
Unlike section 6316.1, there is no reference to "actual custody" in section 6316.2. Subdivision (f) of section 6316.2 provides in part, "[a] commitment or a recommitment under Section 6316.1 [sic] shall be for a period of two years from the date of termination of the previous commitment." The reference to section 6316.1 in subdivision (f) is nonsensical, and we are convinced the Legislature intended to refer to commitment or recommitment under section 6316.2. We are also convinced that had the Legislature intended the two-year extended period of commitment under section 6316.2 to be determined only by the amount of time spent in actual custody, it would have said so.
Sections 6316.1 and 6316.2 are part of the legislative scheme. When a patient has been in actual custody for the longest term of imprisonment which could have been imposed for his crimes, outpatient status will not affect the running of the time on any extension of the MDSO commitment.
Contrary to the People's argument, the procedures set forth in section 6316.2 apply whether the patient is in actual custody or on outpatient status. Subdivision (g) of section 6316.2 provides "[a] person committed under this section to the State Department of Mental Health shall be eligible for outpatient release as provided in this article." Subsection (k) of section 6316.2 provides in part that a "person committed pursuant to this section shall be confined in a state hospital unless released as an outpatient as provided in Section 6325.1." Section 6325.1 provides that a person committed as an MDSO may be placed in outpatient status pursuant to section 1600 et seq. of the Penal Code. Thus, section 6316.2 expressly recognizes that some persons coming within its purview may be outpatients.
*1298 Nor is there anything about the difference between the annual review of outpatient status (Pen. Code, § 1606) and the biennial renewal of an MDSO commitment that leads us to the conclusion that section 6316.2 is not intended to apply to outpatients.
(3a) The People next contend that when Gunderson stipulated to continue as an outpatient he necessarily stipulated to his ongoing commitment under the MDSO statute. They argue that Gunderson cannot now complain about the procedural defects that were waived by the stipulation.
Subdivision (e) of section 6316.2 provides in part that "[t]he patient shall be entitled to the rights guaranteed under the Federal and State Constitutions for criminal proceedings." (4) The federal Constitution requires that the record affirmatively show a waiver of constitutional rights so that a reviewing court can determine whether a guilty plea was knowingly and intelligently made. (Boykin v. Alabama (1969) 395 U.S. 238 [23 L.Ed.2d 274, 89 S.Ct. 1709]; In re Tahl (1969) 1 Cal.3d 122 [81 Cal. Rptr. 577, 460 P.2d 449].)
(3b) Here, not only is the record bereft of any waiver of rights, but no petition was filed with accompanying affidavits specifying the factual basis for believing that Gunderson continued to represent a substantial danger of bodily harm to others. (§ 6316.2, subd. (a)(2).) The absence of such a petition makes it difficult to see how Gunderson could have knowingly and intelligently admitted the factual allegations necessary to support such a finding. The record raises doubts whether the Marin County prosecutor, no less Gunderson, understood that by stipulating to remain on outpatient status, Gunderson was admitting all the factual allegations necessary for an extended commitment under section 6316.2 and waiving all of his procedural rights under that section.
The People's argument that Gunderson should be required to show prejudice from the lack of a waiver of rights, misapprehends the Boykin-Tahl rule: unless the record affirmatively shows that a guilty plea was knowingly and intelligently made it cannot stand. The defendant does not have the burden of showing prejudice.
People v. Dias (1985) 170 Cal. App.3d 756, 762 [216 Cal. Rptr. 295], holds that although the time limitations for filing a petition to extend an MDSO commitment are not jurisdictional, an order for an extended commitment will generally be void if the petition was filed after the commitment expired or so close to the expiration date that the defendant does not have a fair opportunity to prepare for trial. There is an exception to the general rule that a valid extension will not result from a petition that is filed after the *1299 commitment expires. It occurs where as a result of legislative or judicial change, the term expired without a reasonable opportunity to prepare and file the petition. (Ibid.)
In Dias, the prosecutor mistakenly believed that the time the defendant spent confined in private hospitals should not be included in calculating the time spent in "actual custody." As a result the maximum term expired before a petition to extend the commitment was filed. The defendant moved to dismiss the petition, but the trial court denied the motion. In upholding the denial of the motion the Court of Appeal stated: "The error resulted from a mistake of law on an issue where the relevant statute was not explicit and there was no controlling judicial decision directly on point. In this situation, we do not believe the error should be fatal to the extended commitment order." (170 Cal. App.3d at p. 763.)
Whether or not Dias is correct in its pronouncement that time limits are not jurisdictional, that case is inapplicable here. In the instant case the relevant statutes and judicial decisions are sufficiently explicit. There was no miscalculation of time based on a statutory ambiguity. To hold that Gunderson is still under commitment would be to ignore the plain language of subdivision (a) to section 6316.2 that a commitment can be extended "only under the procedure set forth in this section...."
The order revoking Gunderson's outpatient status is reversed.
Stone (S.J.), P.J., and Abbe, J.,[*] concurred.
Respondent's petition for review by the Supreme Court was denied June 26, 1991.
NOTES
[1]  All statutory references are to the Welfare and Institutions Code unless otherwise stated.
[2]  MDSO laws were repealed by Statutes 1981, chapter 928, section 2, page 3485; however, they remain applicable to persons previously committed and subject to recommitment. (People v. Lamport (1985) 165 Cal. App.3d 716, 718, fn. 2 [211 Cal. Rptr. 665].)
[*]   Retired Associate Justice of the Court of Appeal sitting under assignment by the Chairperson of the Judicial Council.
