
58 S.W.3d 513 (2001)
STATE of Missouri, ex rel. Jeremiah W. (Jay) NIXON, Attorney General, Relator,
v.
The Honorable James H. KELLY, Associate Circuit Judge, St. Francois County, and Shirley Williford, Circuit Clerk, St. Francois County, Respondents.
No. SC 83319.
Supreme Court of Missouri, En Banc.
October 23, 2001.
*514 Jeremiah W. (Jay) Nixon, Atty. Gen., Troy Allen, Asst. Atty. Gen., Jefferson City, for relator.
Douglas R. Hoff, Asst. Public Defender, St. Louis, for respondents.
LAURA DENVIR STITH, Judge.
This is an original proceeding in certiorari to review the issuance of a writ of habeas corpus directing the Department of Corrections ("DOC") to grant Paul A. Haldeman more than seven months of "jail-time" credit on his May 13, 1996, sentence for sexual assault. The habeas court granted credit for the time Mr. Haldeman had already served in prison from October 6, 1995, to May 13, 1996, on an April 1994 conviction. Mr. Haldeman argued that this time was "related to" his May 1996 conviction because both convictions involved sexual assaults on his stepdaughter and the assaults originally had been charged and tried together until a new trial was ordered on one of the assaults. Respondent agreed, citing section 558.031, RSMo Supp.1995, which provides the time a prisoner serves will be credited to more than one offense if the time in custody is "related to" both offenses.
The record below granting the writ of habeas corpus is quashed for two reasons. First, while Respondent is correct that section 1.160(2), RSMo 1994, provides that *515 a person awaiting sentencing shall receive the benefit of any lessening of punishment "by any alteration of the law creating the offense prior to original sentencing," that section simply is not applicable. Here, the change in the law resulted from an alteration of section 558.031, governing determination of jail-time credit, not an alteration of the sexual assault laws creating the offense of which Mr. Haldeman was convicted.
Second, section 558.031 does not apply in this case because Mr. Haldeman's time in custody prior to May 13, 1996, was not legally "related to" his May 1996 conviction merely because both cases involved sexual assaults on his stepdaughter and both were originally charged and tried together.
FACTS AND PROCEDURAL BACKGROUND
In April 1994, a jury convicted Paul Haldeman of two counts of sexual assault in the first degree, section 556.040, RSMo 1986, in the Circuit Court of St. Louis County. The State had charged that, in July 1987 and between October 1 and December 31, 1988, Mr. Haldeman had sexual intercourse with his minor stepdaughter. The jury convicted him of both counts of sexual assault.
On June 10, 1994, the court sentenced Mr. Haldeman to seven years imprisonment on the count involving conduct between October 1 and December 31, 1988 ("Conviction I"). The trial court ordered a new trial on the count involving conduct in July 1987 and released Mr. Haldeman on bond pending appeal of Conviction I. On September 26, 1995, the Court of Appeals affirmed the judgment as to Conviction I.[1] The bond was revoked, and Mr. Haldeman began serving the seven-year sentence on Conviction I on October 6, 1995. In the meantime, the State determined to retry Mr. Haldeman on the count involving conduct in July 1987. On May 13, 1996, the trial court convicted him on that count and sentenced him to another seven-year term ("Conviction II"), which the court ordered to run concurrently with the sentence he was then serving on Conviction I.
The DOC determined that Mr. Haldeman was not entitled to jail-time credit on Conviction II for the time spent in prison on Conviction I prior to his conviction on Conviction II (the time from October 6, 1995 through May 13, 1996).[2] After exhausting his administrative remedies with the DOC, Mr. Haldeman filed a petition for writ of habeas corpus in the circuit court seeking credit for this time on both sentences. Respondent, relying on section 558.031, as amended in 1995, found that Mr. Haldeman was entitled to this jail-time credit because this was time "waiting trial and was related to " both offenses. The State sought review by petition for writ of certiorari, which the Court of Appeals preliminarily granted but then quashed. This Court granted transfer. The trial court's record granting the writ of habeas corpus is now quashed.
*516 STANDARD OF REVIEW
A person may seek a petition for a writ of habeas corpus when the person is "restrained of liberty within this state [in order] to inquire into the cause of such restraint." Rule 91.01. Rule 91 proceedings are limited to determining the facial validity of confinement on the basis of the entire record of the proceeding in question. State ex rel. Simmons v. White, 866 S.W.2d 443, 445 (Mo. banc 1993). Mr. Haldeman was restrained of his liberty within this state and was inquiring into the cause of his restraint; therefore, a petition for a writ of habeas corpus was appropriate.
Because there is no appeal from the trial court's grant of a habeas petition, if the State seeks to have the record of the writ of habeas corpus quashed, it does so by filing a petition for writ of certiorari, as it did here. Jones v. State, 471 S.W.2d 166 (Mo. banc 1971). "When the Attorney General seeks a writ of certiorari, the writ issues as a matter of course and of right,"[3] so that an appellate court can review the propriety of the habeas court's grant of the writ. "The chief purpose of certiorari [is] to confine an inferior tribunal within its jurisdictional limits ...., the writ affords relief not only where the inferior tribunal is without jurisdiction but also where such tribunal abuses or acts in excess of its rightful jurisdiction." State ex rel. Reorganized Sch. Dist. R-9 v. Windes, 513 S.W.2d 385, 390 (Mo.1974). The writ of certiorari "presents only questions of law on the record brought up by the return and does not permit consideration of issues of fact." Id. See also State ex rel. Danforth v. Bondurant, 566 S.W.2d 478, 480 (Mo. banc 1978).
ANALYSIS
A. An Amendment to the Jail-Time Credit Statute is Not An Amendment to the Statute Creating An Offense.
Respondent argues Mr. Haldeman is entitled to jail-time credit on Conviction II for the period from October 6, 1995 until May 13, 1996, based on Respondent's interpretation of section 1.160(2), RSMo 1994, and on the interrelationship of that section with section 558.031, as amended in 1995.
The 1994 version of section 1.160 states:
No offense committed and no fine, penalty or forfeiture incurred, or prosecution commenced or pending previous to or at the time when any statutory provision is repealed or amended, shall be affected by the repeal or amendment, but the trial and punishment of all such offenses, and the recovery of the fines, penalties or forfeitures shall be had, in all respects, as if the provision had not been repealed or amended, except:
(1) That all such proceedings shall be conducted according to existing procedural laws; and
(2) That if the penalty or punishment for any offense is reduced or lessened by any alteration of the law creating the offense prior to original sentencing, the penalty or punishment shall be assessed according to the amendatory law.
section 1.160. Respondent's argument based on this section is somewhat complex. He notes that Mr. Haldeman was not sentenced on Conviction II until May 1996. He argues that section 1.160(2), quoted above, therefore entitles Mr. Haldeman to the benefit of any changes in the law that might have lessened the punishment for sexual assault between the time Mr. Haldeman committed the assaults and the *517 time of his sentencing in May 1996. Respondent then notes that section 558.031 was amended in 1995, prior to Mr. Haldeman's sentencing, and argues that Mr. Haldeman should be allowed to take advantage of this change in the law because it lessened the punishment for his crime when it changed the way jail-time credit is calculated.
More specifically, prior to 1995, in order to be entitled to jail-time credit for a particular period, a prisoner had to show that he spent that time in prison because he was awaiting trial for that offense. section 558.031, RSMo 1986. In 1995, section 558.031 was revised to provide:
A sentence of imprisonment shall commence when a person convicted of a crime in this state is received into the custody of the department of corrections or other place of confinement where the offender is sentenced. Such person shall receive credit toward the service of a sentence of imprisonment for all time in prison, jail or custody after the offense occurred and before the commencement of the sentence, when the time in custody was related to that offense....
(emphasis added). Respondent argues that the time Mr. Haldeman spent in prison between October 6, 1995, and May 13, 1996, was "related to" both of his offenses, so that he is entitled to an earlier release from prison under the 1995 version of section 558.031 than under the pre-1995 version of that section. Therefore, Respondent argues, the amendment to section 558.031 lessens the punishment for Mr. Haldeman's offense, and so, under section 1.160(2), Mr. Haldeman is entitled to take advantage of this change in the law even though it was enacted long after his crime was committed.
In support, Respondent cites to State v. Whiteaker, 499 S.W.2d 412 (Mo.1973), that was decided under a prior version of section 1.160 and a predecessor to section 558.031. In Whiteaker, defendant similarly argued that the then-current version of Missouri's jail-time credit statute had the effect of lessening the punishment for his crime, and the then-current version of section 1.160 provided that a defendant was entitled to be sentenced according to the laws existing at the time of his sentencing if they had the effect of lessening his punishment. After reviewing the 1969 versions of sections 1.160 and 546.615[4], this Court agreed, expressly stating that because section 546.615 had the "effect of lessening the punishment by reducing the amount of time to be served after conviction by that amount of time spent in jail awaiting trial" and is part of the "existing law," it must be given effect under section 1.160(1), RSMo 1969.[5]Whiteaker, 499 S.W.2d at 420-421.
Whiteaker was wrongly decided. It was premised on a misreading of section 1.160(2), as is Respondent's argument. The version of section 1.160(2) in effect when Whiteaker was decided did not state that a defendant was entitled to the benefit of a change in any law that had the effect of reducing the punishment for his offense. To the contrary, like the 1994 version of section 1.160(2), the 1969 version of that statute stated that a defendant was entitled to the benefit of the lessening of the punishment for an offense "by any alteration *518 of the law creating the offense...." section 1.160(2), RSMo 1994 and RSMo 1969 (emphasis added). Prior cases, other than Whiteaker, have correctly interpreted this statute to mean, as it states on its face, that a defendant will be sentenced as prescribed by the law in effect at the time of the offense unless a lesser punishment is required by a change in the law that created the offense.[6] To the extent Whiteaker holds otherwise, it is overruled.
Both of Mr. Haldeman's convictions were under section 556.040, governing sexual assault. That section has not been altered at any relevant time to lessen the penalty or punishment for sexual assault. While it is true, as Respondent notes, that section 558.031, governing the time of commencement of a sentence of imprisonment and credit for jail, prison or custody time, was amended in 1995, section 558.031 is not the law that created the offense of which Mr. Haldeman was convicted. Therefore, the fact that section 558.031 was changed after Mr. Haldeman committed his crimes but before his sentencing is irrelevant and does not provide him with the right to be sentenced according to the version of section 558.031 in effect at the time of sentencing.
B. Time in Custody Must Be Related to Second Sentence.
Even had Whiteaker been correctly decided, Mr. Haldeman would not be entitled to relief. The 1995 version of section 558.031 does not permit him to seek credit on his sentence for the time he was imprisoned prior to May 13, 1996. As noted earlier, section 558.031 states in pertinent part that a person who is sentenced in this state "shall receive credit toward the service of a sentence of imprisonment for all time in prison, jail or custody after the offense occurred and before the commencement of the sentence, when the time in custody was related to that offense." Id. (emphasis added).
In granting Mr. Haldeman's petition for writ of habeas corpus, Respondent noted that the two offenses of which Mr. Haldeman was convicted originally had been charged in the same case and tried at the same time. He concluded, without further explanation, that all of Mr. Haldeman's time in prison after his original conviction, therefore, should be considered `related to' both offenses, citing Goings v. Missouri Department of Corrections, 6 S.W.3d 906 (Mo. banc 1999).[7] Respondent reached this conclusion despite the fact that Mr. Haldeman asked for and received a new trial on one of the convictions and was not convicted of it until May of 1996.
Nothing in either section 558.031 or Goings provides that a prisoner's time in custody can be considered "related to" an offense in this circumstance, however. The habeas court's analysis simply reads Goings too broadly. It is not the relationship of the specific facts underlying two convictions, or the fact that two charges were initially tried at the same time and involved the same victim, that is determinative of jail-time credit for purposes of section 558.031. Under section 558.031, it *519 is to "the time in custody" that the second conviction must be related.
Goings dealt with just such a situation. Mr. Goings was on parole for Charge 1 when he was arrested for Charge 2. Because of his arrest for Charge 2, his parole on Charge 1 was revoked and he was placed in prison. He remained in prison while awaiting his trial on Charge 2, of which he was eventually convicted. This Court held that the time that Mr. Goings spent in custody prior to receiving his sentence on Charge 2 was "related to" that sentence because it was Goings' arrest on Charge 2 that resulted in revocation of parole on Charge 1 and returned him to custody.
In this case, there is no similar relationship between Conviction II and Mr. Haldeman's time in custody on Conviction I (i.e., the time prior to Conviction II on May 13, 1996). It is true some of the facts surrounding both convictions are similar because they both involved sexual assaults of the same victim, and that similarity permitted the State to charge and try Mr. Haldeman for the two crimes at the same time. But Respondent cites no authority for the proposition that, under these facts, Mr. Haldeman's time in custody on Conviction I also constitutes time in custody related to Conviction II. To the contrary, and unlike in Goings, even absent Mr. Haldeman's arrest, trial or conviction on Conviction II, he would have been in prison on Conviction I. Absent Conviction I, there is nothing in the record to indicate that he would not have been out on bail on the charge that resulted in Conviction II until he was convicted of it on May 13, 1996. Mr. Haldeman's time in prison prior to May 13, 1996, related solely to Conviction I. For these reasons, he is not entitled to jail-time credit on Conviction II for that period.[8]
The trial court's decision granting the writ of habeas corpus is reversed and the record is quashed.
ALL CONCUR.
NOTES
[1]  See State v. Haldeman, 910 S.W.2d 319 (Mo. App. E.D.1995)
[2]  Mr. Haldeman's maximum release date for Conviction I is August 8, 2002 and for Conviction II is April 4, 2003. Mr. Haldeman was conditionally released when the trial court granted the writ of habeas corpus and so he is not currently in prison. However, this case is not moot because Mr. Haldeman is still subject to parole, which could be revoked, and he could be again committed to prison until his maximum release dates. See sec. 558.031.5. "Under such circumstances, it is appropriate to decide the issue instead of dismissing the case as moot." Boone v. Danforth, 463 S.W.2d 825, 827 (Mo. banc 1971) (citations omitted).
[3]  State ex rel. Taylor v. Blair, 357 Mo. 586, 210 S.W.2d 1, 3-4 (1948).
[4]  Section 546.615 was repealed effective January 1, 1979, and replaced by section 558.031.
[5]  The 1994 amendment to subparagraph (1) substituted the phrase "existing procedural laws" for "existing laws". § 1.160(1)(emphasis added). Because of the resolution of the other issues raised on appeal, this Court does not address the effect, if any, of this change in section 1.160(1).
[6]  See, e.g., State v. Tivis, 933 S.W.2d 843, 848 n. 3 (Mo.App. W.D.1996) (section 1.160 does not permit the use of the amended definition of "dangerous felony" because it was not an "alteration of the law creating the offense" of second-degree burglary); State v. Williams, 936 S.W.2d 828, 831 (Mo.App. W.D.1996); State v. Dean, 898 S.W.2d 704, 707 (Mo.App. W.D.1995).
[7]  Presumably, the basis for the court's ruling was that, had Mr. Haldeman not been granted a new trial on one of the two charges, he would have been sentenced for them on the same day and would have begun serving both sentences at the same time.
[8]  Respondent contends that the ex post facto clause of article I, section 10, clause 1 of the United States Constitution prohibits the State from applying the 1994 version of section 1.160(1) to deprive Mr. Haldeman of jail time credit. This Court has rejected similar contentions, and does so here, for it is settled that to "fall within the ex post facto prohibition, a law must be retrospectivethat is, `it must apply to events occurring before its enactment'and it `must disadvantage the offender affected by it' .... by altering the definition of criminal conduct or increasing the punishment for the crime." Lynce v. Mathis, 519 U.S. 433, 441, 117 S.Ct. 891, 137 L.Ed.2d 63 (1997) (citation omitted). As this Court has previously held, "[s]ection 1.160 does not change the offense of conviction nor does it authorize an increased penalty." State v. Sumlin, 820 S.W.2d 487, 492 (Mo. banc 1991). See also Dean, 898 S.W.2d at 707. The ex post facto clause is not implicated.
