
739 P.2d 1232 (1987)
Randy LIGHTLY, Appellant (Defendant),
v.
The STATE of Wyoming, Appellee (Plaintiff).
No. 86-175.
Supreme Court of Wyoming.
July 24, 1987.
Leonard D. Munker, State Public Defender, Julie D. Naylor, Appellate Counsel, Cheyenne, for appellant (defendant).
A.G. McClintock, Atty. Gen., John W. Renneisen, Sr. Asst. Atty. Gen., and Shirley Kingston, Asst. Atty. Gen., for appellee (plaintiff).
Before BROWN, C.J., and THOMAS, CARDINE, URBIGKIT and MACY, JJ.
THOMAS, Justice.
The only question in this case is whether Randy Lightly is entitled to credit against the maximum sentence imposed by the district court for time spent in the Carbon County Jail prior to the imposition of sentence. The district court specifically did not allow credit against the maximum sentence for the time that Lightly was confined prior to sentence. The propriety of the district court's sentence depends upon whether Lightly was in state custody pending the disposition of the charges against *1233 him or was held as a federal prisoner. Whatever the likelihood is that the district court was justified in its belief that Lightly was a federal prisoner, the record does not reflect that fact. On this record, under the law, the credit for pre-sentence confinement must be granted. We reverse the denial by the district court of Lightly's motion for correction of sentence and mandate that the sentence be modified by the credit of 85 days against the maximum sentence.
In his brief, Lightly states one issue:
"Whether the trial court abused its discretion in refusing to give credit against appellant's sentence for time served in pre-sentence confinement."
In the Brief of Appellee, filed on behalf of the State, the issue is defined in this way:
"Whether the trial court abused its discretion in refusing to give appellant credit for time served in pre-sentence confinement, against either his minimum or maximum sentence?"
On July 31, 1983, Lightly was arrested in Carbon County. A complaint and criminal warrant reflect that he was charged with intentionally placing a victim in fear of immediate bodily injury while committing a larceny in violation of §§ 6-2-401 and 6-3-402, W.S. 1977, and a second count of stealing and carrying away the victim's automobile in violation of § 6-3-402(c)(i), W.S. 1977. Prior to the events which led to his arrest, Lightly was being transported from a federal penitentiary in California to a federal penitentiary at Leavenworth, Kansas. While in temporary confinement in the Albany County jail at Laramie, he escaped. He made his way to Rawlins and there accosted a couple from Washington who were near their car in a motel parking lot. Lightly demanded that they give him their money and their car and manifested to them that he was concealing a weapon. The people from Washington, fearing for their safety, complied with Lightly's demands, and he then fled in the stolen car. He was apprehended on the interstate highway west of Rawlins.
Following a preliminary examination, Lightly was bound over to the district court to answer one charge of robbery and one charge of larceny. When he was arraigned in the district court, he indicated that he believed he suffered from a mental illness. In accordance with the statute (§ 7-11-303, W.S. 1977), the court ordered an examination which was conducted at the jail in Carbon County. The findings of the examiner were negative with respect to any mental illness or deficiency at the time of the commission of the crime or at the time of the proceedings. The examiner also reported that Lightly was competent to proceed. At a subsequent court appearance, Lightly then entered a plea of guilty to the robbery charge, and the State agreed to drop the larceny charge and not file any other charges in connection with the incident. Lightly then was sentenced to a term of not less than seven nor more than ten years in the state penitentiary, with no credit for his pre-sentence confinement against either the maximum or minimum sentence. About two and three-fourth years later, Lightly filed a pro se motion pursuant to Rule 36, W.R.Cr.P., attacking the legality of his sentence and requesting that he be given credit for his pre-sentence confinement. The motion was timely because a motion to correct an illegal sentence may be brought at any time. Rule 36, W.R.Cr.P. Lightly's motion was denied by the district court, and this appeal then was taken.
Recently, in Harley v. State, Wyo., 737 P.2d 750 (1987), we held that Harley was entitled to credit for pre-sentence confinement against his maximum sentence and relied upon the rule expressed in Jones v. State, Wyo., 602 P.2d 378, 381 (1979), that:
"* * * [A] trial judge has discretion to deny or grant credit for time served in pre-sentence custody where: (1) the pre-sentence custody is not due to the defendant's indigency, and (2) the sum of the time spent in pre-sentence custody plus the sentence does not exceed the maximum allowable sentence."[1]
*1234 If Lightly was in custody because of his indigency or if the sum of his time in pre-sentence confinement plus the sentence exceeds the maximum allowable term, he is entitled to relief. On this record, both of those things occurred.
The State concedes that the maximum sentence which was imposed and the pre-sentence confinement exceed the maximum statutory punishment for the offense. The State attempts to distinguish Jones v. State, supra, however, contending that Lightly was not confined because of his indigency but would have been maintained in custody as a federal prisoner even if he had posted bond. The State relies upon his status as a federal prisoner. The assumption is that the federal authorities had requested that Lightly be returned to federal custody when the state proceedings had been completed. The record does not support that assumption. It is true, as the State argues, that Lightly testified about his federal confinement and his escape therefrom at Laramie. Beyond his testimony, there is nothing in this record to indicate that while confined in the Carbon County jail he was being held as a federal prisoner. The tenor of the record is contrary and demonstrates only that he was being held in state custody pursuant to the charges upon which he was convicted. There is nothing to indicate that, absent a status of indigency, he could not have been released upon bail. Recognizing a high probability that he would have remained in custody as a federal prisoner, we still must resolve the case on the basis of the record. So far as this record is concerned, the pre-sentence confinement for Lightly was due to the pending state charges.
In Harley v. State, supra, we held that the critical factor in determining indigency for purpose of crediting pre-sentence confinement is the ability of the defendant to post bond. If the confinement is not attributable to an inability to post bond, the equal protection and due process clauses of the Fourteenth Amendment to the United States Constitution are not implicated. This record demonstrates that Lightly's bond was set at $25,000. There is nothing to indicate that he had the financial resources to post this bond. Had he been able to do so, he well might have obtained his freedom from Wyoming authorities pending disposition and sentencing. Furthermore, he did file an affidavit of indigency, and the public defender was appointed to represent him. The circumstances demonstrated by the record reflect that Lightly was indigent for purposes of entitlement to credit for his pre-sentence confinement.
As the State concedes, the second prong of the test in Jones v. State, supra, also is invoked if Lightly was in state custody. Because the record does not refute the proposition that Lightly was in custody only because of the pending state charges, the law does not permit him to be sentenced to the maximum term under the statute, which he was, without affording him credit for the time in pre-sentence confinement. Unless that result flows, Lightly ultimately serves, or potentially could serve, more than the maximum term authorized by the legislature. This circumstance also justifies Lightly's credit for the 85 days in pre-sentence confinement.
We are cognizant of the fact that part of the pre-sentence confinement in this case was attributable to the necessity for determining mental competency. The parties did not address this issue, and we have had no occasion previously to decide whether credit should be given for incarceration which was made necessary because of a claim of mental incompetency. Other courts have concluded, in the light of their statutes, that credit is appropriate if the determination of competency is necessary in order to dispose of the same crime upon which the defendant is awaiting trial. McNeely v. Henry, App., 100 N.M. 794, 676 P.2d 1359 (1984); State v. Medina, App., 87 *1235 N.M. 394, 534 P.2d 486 (1975). Wyoming does not have a statute relating to this subject, but constitutional constraints require a conclusion that a state cannot discriminate on the basis of confinement required for examinations as to mental competency any more than it can on the basis of indigency. O'Connor v. Donaldson, 422 U.S. 563, 95 S.Ct. 2486, 45 L.Ed.2d 396 (1975); Jackson v. Indiana, 406 U.S. 715, 92 S.Ct. 1845, 32 L.Ed.2d 435 (1972); In Re Banks, 88 Cal. App.3d 864, 152 Cal. Rptr. 111 (1979); Pladson v. State, Minn.App., 385 N.W.2d 406 (1986); State v. Medina, supra; State v. Phelan, 100 Wash.2d 508, 671 P.2d 1212 (1983). If a defendant is maintained in custody for purposes of evaluating mental competency or treating mental illness, he is entitled to credit for that period of incarceration. The alternative is for the state to obtain a valid civil commitment.
In this case, there is no indication that Lightly could not have been examined as an out-patient if he had been able to post bond. Section 7-11-303, W.S. 1977, Cum. Supp. 1986, provides that the determination of mental competency can be made on either in-patient or out-patient basis. Furthermore, the statute provides for posting bail if the court determines the accused is competent to proceed. The indication is that Lightly could not have been held in custody lawfully for purposes of the examination for mental competency if he had the ability to post bond. Under the circumstances, it makes no difference whether he was maintained in pre-sentence confinement for purposes of the mental examination or because he could not post bond.
In this instance, the record demonstrates that Lightly is entitled to a credit against his maximum sentence for pre-sentence confinement of 85 days. He is entitled to that credit because of his indigency, because the maximum term would exceed that authorized by the legislature, and because his retention in custody for purposes of a competency examination would not justify the denial of the credit. The case must be remanded to the district court with direction that Lightly's sentence be modified to encompass a credit of 85 days for pre-sentence confinement against the maximum 10-year sentence. Harley v. State, supra; Heier v. State, Wyo., 727 P.2d 707 (1986).
NOTES
[1]  Prior applications of this test have treated it as conjunctive. E.g., Harley v. State, Wyo., 737 P.2d 750 (1987); Heier v. State, Wyo., 727 P.2d 707 (1986). Further reflection on Jones v. State, Wyo., 606 P.2d 378 (1979), has convinced us that the test should be perceived as disjunctive. Different concerns are raised by each prong of the test. Indigency invokes the constitutional requirements of equal protection; imprisonment in excess of the term set by statute raises jurisdictional concerns.
