
46 Ill. App.3d 208 (1977)
360 N.E.2d 1155
THE PEOPLE OF THE STATE OF ILLINOIS, Plaintiff-Appellee,
v.
HERBERT SPELLER, Defendant-Appellant.
No. 75-450.
Illinois Appellate Court  Fifth District.
Opinion filed March 4, 1977.
*209 Michael J. Rosborough and Ann H. Blandford, both of State Appellate Defender's Office, of Mt. Vernon, for appellant.
Howard L. Hood, State's Attorney, of Murphysboro (Bruce D. Irish and Raymond F. Buckley, Jr., both of Illinois State's Attorneys Association, of counsel), for the People.
Judgment affirmed.
Mr. JUSTICE KARNS delivered the opinion of the court:
Defendant-appellant Herbert Speller was convicted of armed robbery and aggravated battery after a trial by jury in the Circuit Court of Jackson County. He was sentenced to concurrent terms of five to 15 years on the armed robbery count and three years four months to 10 years on the aggravated battery count. On appeal he raises three issues: whether an indictment returned January 17, 1975, charging the commission of offenses on November 19, 1971, was void for failure to allege any facts which would toll the three-year statute of limitations; whether the minimum sentence for the armed robbery conviction should be reduced to four years to conform to the minimum term for armed robbery set out in the Unified Code of Corrections; and whether he should be given credit on his sentences, in accordance with the Unified Code, for some 45 days spent in custody in California before California authorities were notified of the Illinois arrest warrant stemming from the instant charges.
*210 The facts necessary for an understanding of our disposition of the appeal are as follows: At about noon on November 19, 1971, Mrs. Edith Eagleson, an employee of the Rex Loan Company in Carbondale, was robbed and severely beaten on the back of the head with a pistol. While still in the hospital, she selected the defendant's photograph from a "mug shot" book containing pictures of more than 200 black males; she also identified him at trial as her assailant. Lionel Whittington, who operated a restaurant next door to the loan company, rendered assistance to Mrs. Eagleson immediately after the armed robbery. He told the investigating officer, and testified at trial, that he had seen the defendant (whom he had known for about three years) walking past his store in the direction of the loan company shortly before the robbery. He said that defendant was wearing a brown leather jacket and a stocking cap, which description of the robber's clothing matched that given by the victim. Another witness saw a man similarly attired, carrying something in his hands, getting on a bicycle in a parking lot near the loan company at noon the same day; he thought that the man was the defendant.
Three days later, on November 22, 1971, an information was filed charging Herbert Speller with armed robbery and aggravated battery. Attempts to serve an arrest warrant were unsuccessful. In 1974, Jackson County authorities received information from the Los Angeles Police Department that the defendant was in their custody. After commencement of extradition proceedings, the defendant consented to waive extradition and was brought back to Jackson County. At his initial appearance on January 13, 1975, the defendant was served with a copy of the November 22, 1971, information. Four days later the grand jury returned an indictment alleging the same offenses charged in the original information.
At trial, defendant presented an alibi defense. He testified that he had flown from St. Louis to California during the last week of October 1971 and did not leave California for the rest of 1971. Other defense witnesses placed the defendant's arrival in California as early as April 1971. The jury returned guilty verdicts on both charges.
The defendant waived pre-sentence investigation, as permitted by section 5-3-1 of the Unified Code of Corrections (Ill. Rev. Stat. 1975, ch. 38, par. 1005-3-1). At his sentencing hearing, the defendant presented no evidence in mitigation, but asked to be sentenced "under the old law of 1971, which I understand is a probationable offense * * *." Defense counsel told the court that he had discussed the "various ramifications" of sentencing with his client, and that the defendant was electing to be sentenced under the law in effect at the time of the offenses. Counsel also raised for the first time the fact that the indictment on the armed robbery count charged a violation of section 18-1 of the Criminal *211 Code, not section 18-2, and argued that the defendant should therefore be sentenced not for armed robbery, but simple robbery, which in 1971 provided for a sentence of from one to 20 years, with the possibility of probation. The State responded that the text of the indictment and the jury instruction on armed robbery made it clear that "18-1" was a "miswriting" amendable under section 111-5 of the Code of Criminal Procedure (Ill. Rev. Stat. 1975, ch. 38, par. 111-5), and moved to amend the indictment to read "Section 18-2." Defense counsel told the court that his client wished to be sentenced under the law in effect in 1971, regardless of the court's ruling on the State's motion to amend the indictment. After the court granted leave to amend, the defendant repeated that he still wanted to be sentenced under the old law. Defense counsel stated that his client understood the statutory minimum under the 1971 law. After the court pointed out that the defendant could not be admitted to probation after conviction of armed robbery under 1971 law, defense counsel indicated his understanding that the court must give a penitentiary sentence and requested that the court impose the minimum sentence. The State pointed out the senselessness of the attack on Mrs. Eagleson and the defendant's flight to avoid prosecution. The court then imposed concurrent sentences of five to 15 years for armed robbery and three years four months to 10 years for aggravated battery.
 1, 2 Defendant's first contention on appeal is that the prosecution of the instant felonies was not commenced within three years after the commission of the offenses, as required by section 3-5(b) of the Criminal Code (Ill. Rev. Stat. 1971, ch. 38, par. 3-5(b)). It is true that a charge which shows on its face that the offense was not committed within the applicable limitation period, and also fails to allege facts which would avoid the bar of the statute of limitations, is insufficient and subject to dismissal upon attack before trial. (People v. Hawkins, 34 Ill. App.3d 566, 340 N.E.2d 223 (1st Dist. 1975); People v. Munoz, 23 Ill. App.3d 306, 319 N.E.2d 98 (2d Dist. 1974), and cases cited therein.) However, the instant case falls outside that rule for two reasons. First, the prosecution here commenced with the issuance of the information three days after the offenses. (See section 2-16 of the Criminal Code, Ill. Rev. Stat. 1971, ch. 38, par. 2-16.) Second, even had the original information not been issued, by his failure to raise the issue of expiration of the statute of limitations by written motion prior to trial, the defendant waived that issue. See section 114-1(a)(2) and 114-1(b) of the Code of Criminal Procedure, Ill. Rev. Stat. 1971, ch. 38, pars. 114-1(a)(2) and 114-1(b).
 3 Defendant next argues that because the armed robbery of which he was convicted occurred prior to the effective date of the Unified Code of Corrections, but his sentence was after the effective date, section 8-2-4 of the Unified Code entitles him to be sentenced in accord with the *212 more lenient law. (Ill. Rev. Stat. 1975, ch. 38, par. 1008-2-4; People v. Davis, 36 Ill. App.3d 904, 344 N.E.2d 736 (1st Dist. 1976); People v. Wright, 18 Ill. App.3d 1028, 310 N.E.2d 494 (4th Dist. 1974).) We think that a more accurate statement of the rule is that a "defendant must be given an opportunity to elect whether he wishes to be sentenced under the law in effect at the time the offense was committed or under the law in effect at the time of sentencing." (Emphasis added.) (People v. Davis, 36 Ill. App.3d 904, 907, 344 N.E.2d 736, 739; see also People v. Hollins, 51 Ill.2d 68, 280 N.E.2d 710 (1972).) As in the Davis case, the defendant here made his election after a thorough discussion of sentencing alternatives with his attorney. The court also was very careful to determine that the defendant knew that he could not be given probation and that the minimum sentence for armed robbery under the law in effect on November 19, 1971, was five years in the penitentiary. We do not think that the defendant can now be heard to complain of the consequences of his own unambiguous election to be sentenced under the law in effect at the time of the armed robbery. (Because of his election, defendant is not, of course, required to serve the mandatory parole term called for by the Unified Code of Corrections.)
 4 Defendant's final contention borders on the frivolous. He was taken into custody by the Los Angeles Police Department on September 26, 1974, for an alleged offense unrelated to the Illinois charges. On November 9, 1974, the Los Angeles Police Department was notified of the outstanding Illinois arrest warrant, and the defendant was released to Illinois authorities on January 9, 1975. He has already been given credit for his time in custody in California from November 9 to January 9. Now he argues that section 5-8-7(c) of the Unified Code of Corrections (Ill. Rev. Stat. 1975, ch. 38, par. 1005-8-7(c)) requires that he be given credit for the time he spent in jail in California before the Los Angeles police even knew of the instant offenses. Even if the sentencing provisions of the Unified Code of Corrections applied here, this argument would be unavailing. Section 5-8-7(b) makes it clear that credit is conditioned upon the fact of "time spent in custody as a result of the offense for which the sentence was imposed." (Emphasis added.) (Ill. Rev. Stat. 1975, ch. 38, par. 1005-8-7(b).) By no stretch of the imagination was the time spent by the defendant in the California jail before November 9 a result of these Illinois offenses. We agree with the State that subsection (c), which provides that "* * * [a]n offender arrested on one charge and prosecuted on another charge for conduct which occurred prior to his arrest shall be given credit on the maximum term and the minimum term of imprisonment for time spent in custody under the former charge not credited against another sentence," was added to protect the right secured to the defendant under subsection (b), and to prevent the State *213 from depriving the defendant of credit for jail time through technical evasion. See also Ill. Ann. Stat., ch. 38, par. 1005-8-7, Council Commentary, at 514 (Smith-Hurd 1973).
For the foregoing reasons, the judgment and sentences of the Circuit Court of Jackson County are affirmed.
Affirmed.
CARTER, P.J., and EBERSPACHER, J., concur.
