
226 Wis.2d 687 (1999)
594 N.W.2d 791
STATE of Wisconsin EX REL. Michael J. HAGER, Petitioner-Petitioner,
v.
Gary MARTEN, Sheriff, Marathon County Jail, Respondent.
No. 97-3841-W.
Supreme Court of Wisconsin.
Oral argument February 12, 1999.
Decided June 16, 1999.
*688 For the petitioner-petitioner there were briefs and oral argument by Gerhardt F. Getzin, assistant state public defender.
For the respondent the cause was argued by Sally L. Wellman, assistant attorney general, with whom on the briefs was James E. Doyle, attorney general.
¶ 1. JON P. WILCOX, J.
The petitioner, Michael J. Hager, seeks review of an unpublished court of appeals' order denying his petition for a writ of habeas corpus. Hager was held in custody from July 1997 to December 1997, awaiting an examination to determine whether he was competent to stand trial for numerous criminal charges against him. He now seeks dismissal of all of the pending criminal charges and release from custody due to violations of the time limit for a competency examination under Wis. Stat. § 971.14(2)(c)(1997-98).[1]
¶ 2. This case presents two issues for review: (1) Can a petitioner raise an issue of statutory interpretation on a writ of habeas corpus; and (2) If so, does the *689 failure to conduct a competency examination within the time frame of Wis. Stat. § 971.14(2)(c) constitute a jurisdictional defect. We answer the first question in the affirmative; a question of statutory interpretation may be considered on a writ of habeas corpus only if noncompliance with the statute at issue resulted in the restraint of the petitioner's liberty in violation of the constitution or the court's jurisdiction. As to the second issue, we conclude that no jurisdictional defect is present because there was no time limit violation under the statutory section applicable in this case. We further conclude that under the facts of this case. Hager was not denied due process based on the length of his pre-examination confinement. Accordingly, we affirm the court of appeals' order denying the writ of habeas corpus.
¶ 3. The facts are not in dispute. This action stems from four criminal complaints filed against Hager. The first complaint, dated June 10, 1994, involved a charge of operating a motor vehicle while under the influence of an intoxicant, second offense. Hager was present at the initial appearance on August 2, 1994, but failed to appear on October 26, 1994. A bench warrant was issued on October 31, 1994.
¶ 4. The second complaint was filed in June 1996. The complaint charged Hager with five counts of felony failure to pay child support from February 1, 1994, to June 7, 1996. The next proceeding in this action was in December 1996.
¶ 5. On December 18, 1996, Hager was charged in yet another complaint, the third, with two counts of intentionally causing bodily harm to another over the age of 62 and one count of disorderly conduct for an incident involving his parents. The initial appearance for this matter was held on the same day. At the hearing, *690 the Marathon County Circuit Court, Michael J. Hoover, Judge, found reason to doubt Hager's competency to proceed and ordered a competency examination by the Department of Health and Family Services (DHFS).
¶ 6. The competency examination was completed on January 9, 1997, and forwarded to the circuit court. The report concluded that Hager was incompetent to stand trial. However, after being returned from the Winnebago Mental Health Facility (Winnebago), where the examination was conducted, Hager was released from custody on a $1,000 recognizance bond. In both April and May 1997, Hager appeared in court claiming to be competent. Yet, his counsel questioned Hager's ability to participate in formulating a defense. A second competency hearing was scheduled for July 10, 1997; however, Hager failed to show for the hearing, and the circuit court issued a bench warrant for his arrest.
¶ 7. On July 16, 1997, Hager was taken into custody and additional criminal charges (the fourth complaint) were filed for battery to a law enforcement officer, felony bail jumping, resisting an officer, and disorderly conduct. Hager's counsel informed the court that Hager had been found incompetent in the prior pending matters, and raised the question of competency to proceed with the new charges as well. Based on the passage of time from the January 9th report to the new charges, the Marathon County Circuit Court, Vincent K. Howard, Judge, ordered a new competency examination to be conducted at Winnebago. The court acknowledged that this examination was to be conducted within the statutory time limits. The court also ordered $500 cash bond.
*691 ¶ 8. Hager was never taken to Winnebago for the competency examination; unable to post bond, he remained in jail. At a November 5, 1997, hearing, Hager's counsel asked that Hager be released until another competency hearing could be rescheduled. The circuit court authorized a $1,500 signature bond which had to be cosigned by a relative pending the hearing. None of Hager's relatives signed for his release, and he remained in jail.
¶ 9. The competency hearing was originally scheduled for December 12, 1997, but Hager, who was represented by new counsel, requested an outpatient examination to bring his report current. The State stipulated to the outpatient examination and the competency hearing was rescheduled for December 17, 1997. At the hearing, Hager moved to dismiss all of the criminal charges for violation of the time limits imposed under Wis. Stat. § 971.14(2)(c). The Marathon County Circuit Court, Dorothy L. Bain, Judge, denied Hager's motion concluding that dismissal was unsupported in the law and that it would be an extreme measure in light of the previous finding that he was not competent.
¶ 10. The court then proceeded with the competency hearing as scheduled. Based on review of the two medical reports, the testimony from a clinical psychologist who conducted the second competency examination of Hager, and conversations with Hager at the hearing, the circuit court found that Hager was not competent to proceed but would likely become competent within a 12-month period or less. Accordingly, the court ordered medication and treatment be administered, regardless of consent, and that Hager be committed to the custody of DHFS for placement in an appropriate institution, with periodic examinations.
*692 ¶ 11. Consequently, Hager filed petitions for leave to appeal the circuit court's non-final order and for a writ of habeas corpus with the court of appeals. The court of appeals concluded that dismissal of the criminal complaints was not an appropriate remedy and denied all petitions. This court granted Hager's petition for review from the court of appeals' denial of the petition for writ of habeas corpus.
[1,2]
¶ 12. The first question we must address is whether habeas corpus is available to address a question of statutory interpretation. Habeas corpus is a civil proceeding guaranteed by the Wisconsin and United States constitutions "to test the right of a person to his personal liberty." State ex rel. Dowe v. Waukesha County Circuit Court, 184 Wis. 2d 724, 728, 516 N.W.2d 714 (1994). The purpose of the writ of habeas corpus is to protect and vindicate the petitioner's right of personal liberty by releasing the petitioner from illegal restraint. State ex rel. Zdanczewicz v. Snyder, 131 Wis. 2d 147, 151, 388 N.W.2d 612 (1986).
¶ 13. The State challenges Hager's ability to raise an issue of statutory construction on a writ of habeas corpus. However, the court of appeals, in State ex rel. Lockman v. Gerhardstein, 107 Wis. 2d 325, 320 N.W.2d 27 (Ct. App. 1982), addressed this very question.[2]
*693 ¶ 14. The petitioner in Lockman submitted a writ of habeas corpus and discharge of the complaint alleging the final hearing on her involuntary civil commitment was not held within 14 days of her detention as required by Wis. Stat. § 51.20(7)(c)(1979-80). Lockman, 107 Wis. 2d at 326-27. The issue before the court of appeals was whether the 14-day time limit in § 51.20(7)(c) (1979-80) refers to calendar days or business daysa question of statutory construction. Lockman, 107 Wis. 2d at 327. The court concluded that the statute meant 14 calendar days; therefore, the "trial court lost jurisdiction over Lockman as a consequence of its failure to hold a final commitment hearing within fourteen calendar days of Lockman's detention and [it] should have dismissed the proceedings against her." Id. at 328-29.
¶ 15. When considering whether or not to grant habeas corpus review, the habeas court determines only whether the order resulting in the restraint of liberty was made in violation of the constitution, or whether the court which issued the order lacked the jurisdiction or legal authority to do so. Zdanczewicz, 131 Wis. 2d at 151. It follows then that statutory construction may only be considered on habeas corpus review in the context of these constitutional or jurisdictional violations. See State ex rel. Simos v. Burke, 41 Wis. 2d 129, 133, 163 N.W.2d 177 (1968).
¶ 16. To determine whether to grant Hager's writ of habeas corpus for an alleged violation of the statutory time frame in Wis. Stat. § 971.14(2)(c), this court must determine whether noncompliance with the statutory *694 time frame resulted in Hager's restraint of liberty in violation of the constitution, or whether noncompliance with the time frame resulted in a jurisdictional defect. In a habeas corpus action, we apply a de novo standard to issues of law, State ex rel. McMillian v. Dickey, 132 Wis. 2d 266, 276-77, 392 N.W.2d 453 (Ct. App. 1986), and the burden is on the petitioner, here Hager, to demonstrate by a preponderance of the evidence that his detention is illegal, State ex rel. Alvarez v. Lotter, 91 Wis. 2d 329, 334, 283 N.W.2d 408 (Ct. App. 1979).
¶ 17. Thus, we must address whether Hager's five-month stay in the Marathon County jail without the ordered competency examination can be viewed as "illegal." Hager contends that the court ordered an inpatient competency examination under Wis. Stat. § 971.14(2)(a), which immediately triggered the time limits under § 971.14(2)(c). The State, on the other hand, argues that the court ordered the competency examination at Winnebago under § 971.14(2)(am), and that the time limits under subs. (c) were never triggered because Hager was never transported to Winnebago.[3]
¶ 18. Wisconsin Stat. § 971.14(2) provides in relevant part:

*695 (2) EXAMINATION.
(a) If an inpatient examination is determined by the court to be necessary, the defendant may be committed to a suitable mental health facility for the examination period specified in par. (c), which shall be deemed days spent in custody under s. 973.155. If the examination is to be conducted by the department of health and family services, the court shall order the individual to the facility designated by the department of health and family services.
(am) Notwithstanding par. (a), if the court orders the defendant to be examined by the department or a department facility, the department shall determine where the examination will be conducted, who will conduct the examination and whether the examination will be conducted on an inpatient or outpatient basis. Any such outpatient examination shall be conducted in a jail or a locked unit of a facility. In any case under this paragraph in which the department determines that an inpatient examination is necessary, the 15-day period under par. (c) begins upon the arrival of the defendant at the inpatient facility. . . .

(c) Inpatient examinations shall be completed and the report of examination filed within 15 days after the examination is ordered or as specified in par. (am), whichever is applicable, unless, for good cause, the facility or examiner appointed by the court cannot complete the examination within this period and requests an extension. In that case, the court may allow one 15-day extension of the examination period. Outpatient examinations shall be completed and the report of examination filed within 30 days after the examination is ordered. [Emphasis added.]
*696 ¶ 19. Whether Hager was ordered to be examined pursuant to Wis. Stat. § 971.14(2)(a) or (am) depends on the nature of the order for a competency examination. Clearly if the court ordered an inpatient examination under § 971.14(2)(a) as Hager claims it did, § 971.14(2)(c) would have been immediately triggered, and the 15-day time limit would have started to run. Id. However, the record reveals that the circuit court only ordered that the competency examination be conducted at Winnebago. Contrary to Hager's claim, the court did not specify whether Hager was to be examined on an inpatient or outpatient basis.[4]
¶ 20. Wisconsin Stat. § 971.14(2)(am) states that once an examination is ordered to be conducted by a department facility, it is within the department's discretion to determine where the examination will be conducted, by whom, and whether it should be conducted on an inpatient or outpatient basis. Id. If an inpatient examination is required, the 15-day time limit begins upon arrival of the defendant at the facility. Id.
*697 ¶ 21. In this case, the only cognizable order from the circuit court was that Winnebago conduct Hager's competency examination; the court did not specify whether it should be an inpatient or outpatient examination. Winnebago is one of two department facilities within the state. Wis. Stat. § 51.05. Because the court's order required Hager's competency examination to be conducted at Winnebagoa department facility, Wis. Stat. § 971.14(2)(am) governs.
[3]
¶ 22. Pursuant to Wis. Stat. § 971.14(2)(am), the 15-day time limit begins to run upon arrival of the defendant at the facility. Id. However, Hager was never transported to the Winnebago facility. We conclude that the time limits under § 971.14(2)(am) did not start to run.[5] Because Hager's five-month incarceration without the ordered competency examination did not constitute a violation of the time limits of § 971.14(2)(c), the circuit court had jurisdiction, i.e., authority, to issue its order denying Hager's motion to dismiss.
¶ 23. We believe Hager's reliance on Lockman for the proposition that a jurisdictional defect resulted from his delayed competency examination is misplaced. In Lockman, the petitioner was taken into custody pending an involuntary commitment, and she did not receive a final commitment hearing within the *698 statutory time limit under Wis. Stat. § 51.20(7)(1979-80), Wisconsin's civil commitment statute. Lockman, 107 Wis. 2d at 326. Lockman was not charged with any crimes. The Lockman court held that the circuit court lost jurisdiction over Lockman as a consequence of its failure to hold the final commitment hearing within 14 days of her detention and the proceedings against her were dismissed. Id. at 328-29.
¶ 24. This case is distinguishable. Because Lockman was not charged with any crimes, the state had no reason other than the involuntary commitment to keep her in custody beyond the time limits set forth in Wis. Stat. § 51.20. In contrast, Hager was in custody for reasons other than to determine his mental competency to stand trial. Hager remained in custody because he was charged with a series of misdemeanors and felonies for which he could not post bond.[6] The availability of bond distinguishes the competency commitment from civil commitments.[7] Legislative Council Note, 1978, Wis. Stat. Ann. § 971.13 (West 1998). *699 Hager's continued incarceration is simply unlike that of the petitioner in Lockman.
¶ 25. We are also unpersuaded by Hager's argument that his due process rights were violated based on the length of time he was held in custody awaiting a determination of competency to stand trial. Due process requires that the time of commitment bear a reasonable relationship to the underlying purpose of the commitment. Jackson v. Indiana, 406 U.S. 715, 738 (1972). "State courts, in the absence of a statute with a maximum sentence provision, have. . .recognized that the term of commitment should be related to the severity of the crime." State ex rel. Deisinger v. Treffert, 85 Wis. 2d 257, 265, 270 N.W.2d 402 (1978). Thus, due process requires that one found incompetent to stand trial is entitled to release when observatory confinement reaches the length of the potential maximum sentence for the underlying criminal offense. Id. Although Hager had not yet been found incompetent, the crimes he has been charged with carry a maximum sentence which greatly exceeds the 153 days he was in custody prior to his examination. Hager would be given credit for the time he spent in custody. State v. Byrd, 65 Wis. 2d 415, 424-25, 222 N.W.2d 696 (1974). Under these facts, we conclude there was no due process violation.
¶ 26. The State insists that the only due process claim Hager may have is a right to a speedy trial. The right to a speedy trial has both statutory and constitutional manifestations and is incorporated in both the Federal and the Wisconsin constitutions. U.S. Const. Amend. VI, Wis. Const. Art. I § 7. In order to claim the statutory right, a defendant must affirmatively assert it. Wis. Stat. § 971.10. See also State v. Kwitek, 53 Wis. 2d 563, 570, 193 N.W.2d 682 (1972), Kopacka v. State, *700 22 Wis. 2d 457, 460, 126 N.W.2d 78 (1964). Hager did not assert his statutory right to a speedy trial; therefore, the right was not violated.[8]
¶ 27. The parameters of the constitutional right to a speedy trial were outlined in Barker v. Wingo, 407 U.S. 514 (1972) and recognized by this court in Day v. State, 61 Wis. 2d 236, 212 N.W.2d 489 (1973). These cases dictate that whether a defendant's right to a speedy trial has been violated is to be determined on a case-by-case basis. The determination is to be made upon a consideration of a number of factors, "including the length of delay, the reason for the delay, whether a demand for a speedy trial was made and whether the delay resulted in prejudice to the defendant." State ex rel. Rabe v. Ferris, 97 Wis. 2d 63, 67, 293 N.W.2d 151 (1980). Because Hager does not claim his constitutional right to a speedy trial was denied, we need not determine whether the delay in the competency examination was constitutionally impermissible. Id. at 68.
¶ 28. To summarize, we conclude that the circuit court's order denying Hager's motion to dismiss was not made in violation of the constitution, nor was the court without jurisdiction to issue the order. We further conclude that Hager's due process rights were not *701 violated. Accordingly, Hager's writ of habeas corpus must be denied.
¶ 29. Both parties filed miscellaneous motions which were held in abeyance pending the decision by this court. The State filed a motion to strike the petitioner's brief and appendix, and the petitioner filed a motion to supplement the record; we now deny both motions. The petitioner also filed a "motion regarding caption." The parties agree that despite the caption in this case, the real parties in interest are Petitioner-petitioner and the State of Wisconsin as represented by the Wisconsin Attorney General's office. We so order.
By the Court.  The order of the court of appeals is affirmed.
¶ 30. SHIRLEY S. ABRAHAMSON, CHIEF JUSTICE (concurring).
I agree with the State that a mistake was made in this case. No one  not the court, not the prosecutor, not defense counsel, not jail officials, not the Department of Health and Family Services, not any mental health facility and not Michael Hager  could have intended Michael Hager to remain in jail for five months without having his competency evaluation completed and without any action of any kind taken on his case. Yet for reasons unexplained on the record, no one realized that Michael Hager was sitting in the county jail for five months without any activity on his case.
¶ 31. Although the circuit court ordered Hager's evaluation from the bench, no written court order was ever issued. Whoever was supposed to prepare the order so that Hager could be transported to the appropriate institution for evaluation apparently failed to do so. The only written record we have is a transcript of *702 the circuit court's statements from the bench, and those statements are brief. I agree with the State that on this record, it is impossible to determine whether the circuit court intended to order an evaluation under Wis. Stat. § 971.14(2)(a) or under Wis. Stat. § 971.14(2)(am).
¶ 32. The State is also correct, I think, in concluding that regardless of whether the circuit court was acting under Wis. Stat. § 971.14(2)(a) or Wis. Stat. § 971.14(2)(am), no time limits ever began to run in this case. The 15-day period under § 971.14(2)(am) begins upon the arrival of a defendant at the inpatient facility. Everyone agrees that Hager never arrived at an inpatient facility.
¶ 33. The 15-day and 30-day periods under Wis. Stat. § 971.14(2)(c) begin after the examination is ordered by the circuit court. These time periods do not apply in this case, in my opinion, because no written order for a competency examination was ever actually issued by the circuit court. Although the statutes do not expressly require the circuit court order to be in writing, unless the order is in writing and issued the participants in the justice system have no notice of the circuit court's decision and have no notice of what action must be taken. I conclude that under the circumstances of this case, a circuit court order pursuant to § 971.14(2)(a) must be in writing to trigger the time periods set forth in § 971.14(2)(c). Because no such written order was issued, I conclude that the 15-day and 30-day periods prescribed in § 971.14(2)(c) were not triggered in the present case.
¶ 34. If there is anyone in jail who cannot fend for himself, it is the incompetent individual. Michael Hager fell through the cracks. The legal system failed him. Yet the system offers Hager no remedy for his five *703 months in jail and the delay of his case. I am compelled to concur in the mandate because I have not been persuaded that Hager's due process rights have been violated.
¶ 35. For the reasons stated, I concur.
¶ 36. I am authorized to state that JUSTICE ANN WALSH BRADLEY joins this concurrence.
NOTES
[1]  All statutory references are to the 1997-98 version of the statutes unless otherwise noted.
[2]  Other courts have addressed questions of statutory construction on a writ of habeas corpus. See e.g., State ex rel. Angela M. W. v. Kruzicki, 197 Wis. 2d 532, 545-47, 541 N.W.2d 482 (Ct. App. 1995), rev'd by 209 Wis. 2d 112, 121, 561 N.W.2d 729 (1997)(issue presented in habeas corpus petition was whether a viable fetus is included in the definition of "child" provided in Wis. Stat. § 48.02(2)(1995-96)); and State ex rel. Jacobus v. State, 208 Wis. 2d 39, 47, 559 N.W.2d 900 (1997)(habeas corpus petition raised question whether bail jumping convictions based solely upon consumption of alcohol violated state policy set forth in Wis. Stat. § 51.45(1)(1991-92)).
[3]  The State has argued in the alternative throughout this appeal. The State contends the record is inadequate to review the issues petitioner raises in this case; the time limits under Wis. Stat. § 971.14(2)(c) never started running; even if they did, the time limits are directory, not mandatory; and even if the time limits are mandatory, Hager is not entitled to the relief requested. We agree with the State's position that the time limits were never triggered in this case.
[4]  The confusion generated by the court order in Hager's case is due, in part, to the fact that Judge Howard's order was not reduced to writing. Hager had previously been given a competency hearing at Winnebago on an inpatient basis pursuant to a written order. While that first order is not at issue in this appeal, Hager seems to have interpreted Judge Howard's response to the assistant district attorney's question of whether the second evaluation "would again be at Winnebago" ("[i]f the last one was there, yes"), as ordering an inpatient examination and thus triggering the time limits of Wis. Stat. § 971.14(2)(c). We do not agree that the facts support such a conclusion. It is clear that a written order may have prevented the unfortunate circumstances of this case.
[5]  Both parties addressed in their briefs and at oral argument, the question of whether the time limits in Wis. Stat. § 971.14(2)(c) are mandatory or directory. Because Hager's order fell under subs. (2)(am), and because he never reached the department facility, we conclude that the time limits were not triggered. The question of whether the time limits are mandatory or directory need only be considered if and when the time limits are triggered and violated.
[6]  The remedy for a defendant's financial inability to post bond is that he be given credit for the time spent in custody prior to conviction. Byrd v. State, 65 Wis. 2d 415, 424-25, 222 N.W.2d 696 (1974). One subject to a civil commitment has no such remedy.
[7]  Although temporary deprivation of a defendant's liberty can be justified upon a finding of probable cause that an offense was committed, "the state's interest in depriving the defendant of liberty prior to conviction is arguably exhausted by the time he or she is admitted to bail." Legislative Council Note, 1978, Wis. Stat. Ann. § 971.13 (West 1998). Once a defendant is admitted to bail, "the basis for distinguishing between competency and civil commitments, either in the basis upon which the defendant is deprived of liberty or in the length or severity of such deprivation, is questionable." Id.
[8]  Hager incorrectly claims that he could not assert his right to a speedy trial due to the fact that no arraignment had occurred. The speedy trial statute, Wis. Stat. § 971.10(2)(a), states that the time starts to run from the "date trial is demanded by any party in writing or on the record." The right may also attach when a complaint and warrant are issued, State v. Lemay, 155 Wis. 2d 202, 455 N.W.2d 233 (1990), or at the time of arrest or criminal charging and continues through sentencing. State v. Allen, 179 Wis. 2d 67, 505 N.W.2d 801 (Ct. App. 1993).
