(1) Except as otherwise provided in this section, if a defendant is not brought to trial on the issues raised by the complaint, information, or indictment within six months from the date of the entry of a plea of not guilty, he shall be discharged from custody if he has not been admitted to bail, and, whether in custody or on bail, the pending charges shall be dismissed, and the defendant shall not again be indicted, informed against, or committed for the same offense, or for another offense based upon the same act or series of acts arising out of the same criminal episode.
(2) If trial results in conviction which is reversed on appeal, any new trial must be commenced within six months after the date of the receipt by the trial court of the mandate from the appellate court.
(3) If a trial date has been fixed by the court, and thereafter the defendant requests and is granted a continuance for trial, the period within which the trial shall be had is extended for an additional six-month period from the date upon which the continuance was granted.
(3.5) If a trial date has been fixed by the court and the defendant fails to make an appearance in person on the trial date, the period within which the trial shall be had is extended for an additional six-month period from the date of the defendant's next appearance.
(4) If a trial date has been fixed by the court, and thereafter the prosecuting attorney requests and is granted a continuance, the time is not thereby extended within which the trial shall be had, as is provided in subsection (1) of this section, unless the defendant in person or by his counsel in open court of record expressly agrees to the continuance or unless the defendant without making an appearance before the court in person or by his counsel files a dated written waiver of his rights to a speedy trial pursuant to this section and files an agreement to the continuance signed by the defendant. The time for trial, in the event of such agreement, is then extended by the number of days intervening between the granting of such continuance and the date to which trial is continued.
(5) To be entitled to a dismissal under subsection (1) of this section, the defendant must move for dismissal prior to the commencement of his trial and prior to any pretrial motions which are set for hearing immediately before the trial or prior to the entry of a plea of guilty to the charge or an included offense. Failure to so move is a waiver of the defendant's rights under this section.
(5.1) If a trial date is offered by the court to a defendant who is represented by counsel and neither the defendant nor his counsel expressly objects to the offered date as being beyond the time within which such trial shall be had pursuant to this section, then the period within which the trial shall be had is extended until such trial date and may be extended further pursuant to any other applicable provisions of this section.
(6) In computing the time within which a defendant shall be brought to trial as provided in subsection (1) of this section, the following periods of time shall be excluded:
(a) Any period during which the defendant is incompetent to stand trial, or is unable to appear by reason of illness or physical disability, or is under observation or examination at any time after the issue of the defendant's mental condition, insanity, incompetency, or impaired mental condition is raised;
(b) The period of delay caused by an interlocutory appeal whether commenced by the defendant or by the prosecution;
(c) A reasonable period of delay when the defendant is joined for trial with a codefendant as to whom the time for trial has not run and there is good cause for not granting a severance;
(d) The period of delay resulting from the voluntary absence or unavailability of the defendant; however, a defendant shall be considered unavailable whenever his whereabouts are known but his presence for trial cannot be obtained, or he resists being returned to the state for trial;
(e) The period of delay caused by any mistrial, not to exceed three months for each mistrial;
(f) The period of any delay caused at the instance of the defendant;
(g) The period of delay not exceeding six months resulting from a continuance granted at the request of the prosecuting attorney, without the consent of the defendant, if:
(I) The continuance is granted because of the unavailability of evidence material to the state's case, when the prosecuting attorney has exercised due diligence to obtain such evidence and there are reasonable grounds to believe that this evidence will be available at the later date; or
(II) The continuance is granted to allow the prosecuting attorney additional time in felony cases to prepare the state's case and additional time is justified because of exceptional circumstances of the case and the court enters specific findings with respect to the justification;
(h) The period of delay between the new date set for trial following the expiration of the time periods excluded by paragraphs (a), (b), (c), (d), and (f) of this subsection (6), not to exceed three months;
(i) The period of delay between the filing of a motion pursuant to section 18-1-202 (11) and any decision by the court regarding such motion, and if such decision by the court transfers the case to another county, the period of delay until the first appearance of all the parties in a court of appropriate jurisdiction in the county to which the case has been transferred, and in such event the provisions of subsection (7) of this section shall apply.
(7) If a trial date has been fixed by the court and the case is subsequently transferred to a court in another county, the period within which trial must be had is extended for an additional three months from the date of the first appearance of all of the parties in a court of appropriate jurisdiction in the county to which the case has been transferred.