
119 Cal.Rptr.2d 531 (2002)
97 Cal.App.4th 1010
The PEOPLE, Plaintiff and Respondent,
v.
Anthony Karl MACK, Defendant and Appellant.
No. C037421.
Court of Appeal, Third District.
April 19, 2002.
Rehearing Granted May 14, 2002.
*532 William M. Robinson, San Francisco, under appointment by the Court of Appeal, for Defendant and Appellant.
Bill Lockyer, Attorney General, David P. Druliner and Robert R. Anderson, Chief Assistant Attorneys General, Jo Graves, Senior Assistant Attorney General, Stephen G. Herndon and Wanda Hill Rouzan, Supervising Deputy Attorneys General, for Plaintiff and Respondent.
BLEASE, Acting P.J.
In this case we determine the appropriate measure and procedure for the award of conduct credits for time served in prison prior to the invalidation of a judgment of conviction.
A jury convicted defendant Anthony Karl Mack of second degree robbery committed in 1995 and he was sentenced to prison. A federal district court granted his writ of habeas corpus and directed that the judgment of conviction be vacated for failure to allow defendant to represent himself at his jury trial. Upon return to the trial court defendant entered a negotiated plea of guilty to the second degree robbery and was awarded credit on his new sentence only for the actual days of prior prison custody. The trial judge declined to determine the standards by which conduct credits should be awarded for the time spent in prison and referred the matter to the California Department of Corrections (CDC) for its determination.
We shall conclude that, because his conviction was invalidated, defendant was required *533 by statute to be placed in the same position as if no trial had been had. Pursuant to that policy defendant's time in prison custody must be treated as preconviction custody. Although no statute provides for conduct credits in this circumstance, defendant is entitled, by application of principles of equal protection, to conduct credits, measured by the standards of Penal Code section 4019, as if he had spent the prison time in local custody.[1] However, section 4019 is limited by the 15 percent maximum credit provisions of section 2933.1 that apply when the defendant has been convicted, as here, of a felony offense listed in section 667.5. (§§ 2933.1, subds.(a), (c).) We further conclude the CDC is best situated to determine the conduct credits earned pursuant to these standards for the prereversal time spent in prison.
We shall direct that the case be remanded to the trial court to amend the judgment in accordance with this opinion.

FACTUAL AND PROCEDURAL
BACKGROUND
A jury convicted defendant of second degree robbery (§§ 211, 212.5, subd. (c)), committed November 25, 1995, and found true two "strike" allegations (§ 667, subds.(b)-(i)) and a serious felony allegation (§ 667, subd. (a)). He was sentenced to state prison for 30 years to life.
On appeal to this court, defendant contended his motion to represent himself at trial was erroneously denied. We concluded the motion was properly denied as untimely and affirmed the judgment. (The People v. Anthony Karl Mack (Oct. 30, 1997, C023570) [nonpub. opn.].) The California Supreme Court denied defendant's petition for review.[2]
Defendant filed a petition for writ of habeas corpus in the United States District Court for the Eastern District of California. The district court adopted a magistrate's findings that defendant's request to represent himself in the trial court was timely and granted a writ of habeas corpus vacating (thus reversing) the defendant's conviction.
Upon return to the superior court, defendant, represented by the public defender, entered a negotiated plea of guilty to the second degree robbery and admitted one "strike" allegation, pursuant to which he was sentenced to 10 years in prison. Defendant asked the trial court to award him in-prison conduct credits at a rate of one-half (§§ 2930 et seq.), or presentence conduct credits at a rate of one-third (§ 4019, subd. (b)), for the 1,675 days he had served in state custody.
The People responded that defendant was entitled to one third conduct credit for the time in local custody (§ 4019) and up to one fifth percent conduct credit for the time in state custody (§ 1170.12, subd. (a)(5)). The trial court agreed in part with the People, stating, "He's serving time under the strike law. He wasn't earning half-time credits." Defendant responded that his prior sentence had been invalidated and his state confinement prior to the reversal of his conviction must be considered to be presentence time.
The trial court awarded defendant 159 days of custody credits and 78 days of conduct credits for the time spent in local custody. It awarded defendant 1,675 days *534 of in-prison custody credits but declined to determine the standards by which conduct credits should be awarded. It referred the matter to the CDC.[3]

DISCUSSION

I
On appeal the defendant argues that his entitlement to conduct credits for the period served in prison prior to the invalidation of his conviction should be measured by the standards of section 4019 and the credits earned determined by the trial court. We agree, except as limited by section 2933.1.

A.
The People argue that a court order advising CDC whether the three strikes law applies to its conduct credit calculations would intrude impermissibly upon CDC's administrative responsibilities. We disagree. The People have confused the CDC's administrative authority to determine the actual credits earned with the judicial authority to determine the legal measure by which such credits are to be determined.
We are directed by statute to view defendant's time in prison custody prior to the invalidation of the judgment of conviction as if he had not been convicted. "If a judgment against the defendant is reversed, such reversal shall be deemed an order for a new trial, unless the appellate court shall otherwise direct." (§ 1262.) "The granting of a new trial places the parties in the same position as if no trial had been had." (§ 1180; see also 6 Witkin & Epstein, Cal.Criminal Law (3d ed. 2000) Criminal Appeal, § 166, pp. 412-413; Odium v. Duffy (1950) 35 Cal.2d 562, 564, 219 P.2d 785; People v. Hogue (1991) 228 Cal.App.3d 1500, 279 Cal.Rptr. 647; People v. Pettaway (1988) 206 Cal.App.3d 1312, 1327-1328, 254 Cal.Rptr. 436; People v. Diaz (1962) 206 Cal.App.2d 651, 665, 24 Cal.Rptr. 367; see also People v. Buckhalter (2001) 26 Cal.4th 20, 40, fn. 10, 108 Cal.Rptr.2d 625, 25 P.3d 1103.) The invalidation of a judgment of conviction by habeas corpus, as here, sets the case at large as if the defendant had not been tried and convicted. (In re Crow (1971) 4 Cal.3d 613, 620, 94 Cal.Rptr. 254, 483 P.2d 1206.)
The dissent contends that section 1180 is limited to the trial stage of criminal proceedings and does not extend to proceedings following reconviction. (Dis. opn. at p. 540, citing to People v. Hogue, supra, 228 Cal.App.3d 1500, 279 Cal.Rptr. 647 [which did not consider the issue here presented].) While section 1180 plainly includes trial proceedings, it beggars belief that a defendant who is by law placed in the same position as if no trial had been had may be treated differently on reconviction by virtue of the sentence served pursuant to the very conviction that had been invalidated and which gave rise to the application of section 1180. The dissent engages a nonsequitur in seeking policy support by reference to sections which tie presentence credits to a subsequent not a prior conviction. (Dis. opn. at p. 540; §§ 2933.1, 2933.2.) As seen in this case, section 2933.1 does apply to defendant's presentence time served in prison prior to the invalidation of his prior conviction and *535 thus is not in conflict with the application of section 1180.[4]
For these reasons we view defendant's time in prison prior to the invalidation of his prior judgment of conviction as time spent in custody prior to conviction. This requires that we measure his entitlement to conduct credits accordingly.
We next consider how that may be done.

B.
There is no statute which provides for conduct credits for time served in prison prior to the invalidation of a judgment of conviction.
Section 4019 provides for conduct credits for presentence time spent in a local facility.[5] The three strikes law applies to prison custody only "if a defendant has been convicted of a felony ...." (§§ 667, subd. (c), 1170.12, subd. (a)(5)); (People v. Buckhalter, supra, 26 Cal.4th at p. 32, 108 Cal.Rptr.2d 625, 25 P.3d 1103.)
The only statute which expressly addresses the issue of credit for time served in prison prior to the invalidation of a judgment of conviction provides for credit upon a new commitment only for custody credits, the time actually served. (§ 2900.1.)[6]
The anomaly thus presented is that, although the defendant's prereversal time in prison must be viewed as if he had not been convicted, no statute provides for conduct credits in that circumstance.
Resolution of the anomaly requires that we supply a rule based on the manifest policy of the statutes to award presentence credit for presentence time by application of principles of equal protection of the laws.

II
If defendant's presentence, prereversal prison custody had been spent in a local facility he would have been entitled under section 4019 to conduct credits subject to the limitations of section 2933.1.
To treat defendant's prison time the same as if he had spent the time in local custody requires that we extend the statutes applicable to presentence custody to this circumstance pursuant to the equal protection principles announced in People *536 v. Sage (1980) 26 Cal.3d 498, 165 Cal.Rptr. 280, 611 P.2d 874.
Sage considered the resolution of a similar anomaly arising from the former limitations of section 4019. As the section then read, a person who spent time in jail prior to conviction was entitled to conduct credits only when subsequently sentenced in a misdemeanor proceeding. A felon confined in jail awaiting trial did not come within section 4019. As a consequence, since conduct credits were awarded for time in prison only subsequent to conviction (§ 2931) and delivery of the defendant to the CDC (§ 2900), a felon who, by reason (say) of release on bail, served his or her full term in prison received conduct credits for the full sentence while a felon detained pretrial in local custody did not. The court said: "It is the distinction between the detainee/felon and the felon who serves no presentence time that raises equal protection problems." (Sage, supra, 26 Cal.3d at p. 507, 165 Cal.Rptr. 280, 611 P.2d 874.) The court concluded there is no "rational basis for, much less a compelling state interest in, denying presentence conduct credit to detainee/felons.... if earned ...." (Id. at p. 508, 165 Cal.Rptr. 280, 611 P.2d 874, fn. omitted.) To remedy this violation of equal protection required that the rules of section 4019 be extended to the detainee/felon.
We perceive no material distinction between this case and Sage. In Sage the felon was denied conduct credits for time spent in jail prior to conviction. Here the felon is denied conduct credits for time spent in prison prior to a reconviction. To paraphrase Sage, here it is the disparity between the felon who serves his presentence time in local custody, who is entitled to conduct credits, and the felon who serves his presentence time in prison, who is entitled to none, "that raises equal protection problems."
Under the manifest statutory policy of sections 1262 and 1180, the defendant must be placed "in the same position as if no trial had been held." To fulfill that mandate requires the application of the same standard for the award of conduct credits to presentence detainees in prison as would apply to presentence detainees in the county jail.
As noted, the dissent would depart from the plain words of section 1180 on the grounds it does not apply to conduct credits and should be judged by principles of equal protection as if defendant was not placed in the same position as if no trial had been had. Those principles, he argues, are that defendant should be placed in the same position as a "similarly situated defendant" convicted of the same offense, "namely, conduct credits of up to one-fifth of his total prison term and no more than 15 percent of worktime credits." (Dis. opn. at p. 544.) The argument begs the question. By virtue of section 1180, the person similarly situated is the person who has not been convicted, to wit a person who has been confined presentence.
Implicit in the dissenting argument is that defendant's postreversal status should be measured for purposes of equal protection by his prereversal status under the three strikes law. The dissent makes much of Buckhalter's reliance on section 2900.1 in the following quote: "Section 2900.1 ... speaks in terms of a prison sentence already in progress, and, in contrast with section 2900.5, it omits reference to presentence good behavior credits under section 4019. The implication is that once the defendant is committed to prison, his custody is thereafter considered service of his sentence, and a remand with respect to a sentence the defendant is already serving does not render him eligible for credits of the presentence kind. (26 Cal.4th at p. *537 33, 108 Cal.Rptr.2d 625, 25 P.3d 1103, italics added.)" (Dis. opn. at p. 541.)
Section 2900.1 contains two clauses, one dealing with the invalidation of a conviction, at issue here, and the other with the modification of a sentence, at issue in Buckhalter. The dissent misreads section 2900.1 by [con]fusing its two separate clauses. Consequently, it misreads Buckhalter. Section 2900.1 provides in full:
"Where a defendant has served any portion of his sentence under a commitment based upon a judgment which judgment is subsequently declared invalid or which is modified during the term of imprisonment, such time shall be credited upon any subsequent sentence he may receive upon a new commitment for the same criminal act or acts." (Italics added.)
Relying on the modification clause, Buckhalter says: "[Section 2900.1 provides that when, after the defendant has already been committed and begun to serve his sentence, the judgment is modified `during the term of imprisonment,' `such time' already served must be credited against the subsequent sentence. [¶] Section 2900.1 thus speaks in terms of a prison sentence already in progress ...." (26 Cal.4th at p. 33, 108 Cal.Rptr.2d 625, 25 P.3d 1103; emphasis added.) The dissent in quoting Buckhalter has eliminated the very words of section 2900.1, the modification clause, upon which it relied in stating the sentence was "already in progress." Instead, the dissent relies on the fact section 2900.1 credits the time in prison custody prior to the invalidation of a conviction in the same manner as if the sentence was modified upon resentence. This misses the very point at issue, the status, not the fact of the in prison service, and it is the status upon modification which "speaks in terms of a prison sentence already in progress ...." It blinks reality to say that a sentence served prior to the invalidation of the conviction upon which it is based is part of any sentence-already in progress. If the defendant is acquitted following reversal his time in prison was simply dead time and no part of any sentence. It is from the vantage point of the reversal that the status of the inprison time must be viewed.
Thus Buckhalter is not apposite in stating "that good behavior credits under section 4019 [are not] available to persons confined in state prison." (26 Cal.4th at p. 39, fn. 9, 108 Cal.Rptr.2d 625, 25 P.3d 1103.) Buckhalter does not apply in the case where a defendant's conviction is invalidated. It holds that "a felon once sentenced and committed to prison remains, despite a later remand on sentencing issues, in the custody of the Director, serving time against his ultimate sentence. This holds true whether he is confined in the penitentiary itself or is temporarily housed in county jail pending the remand hearing, and whether his sentence ultimately is modified or is left undisturbed." (Id. at p. 40, 108 Cal.Rptr.2d 625, 25 P.3d 1103.)
Consequently, said the court, "the concerns of Sage are not implicated by the treatment of convicted felons, already committed to the custody of the Director, whose cases are later remanded for the correction of sentencing error while their terms are in progress." (Id. at p. 36, 108 Cal.Rptr.2d 625, 25 P.3d 1103.) By contrast, it cannot be said that time served in prison prior to the reversal of a defendant's conviction is time served while the defendant's term was "in progress."[7]
*538 We conclude that defendant should be awarded conduct credits for the time served in prison prior to invalidation of his conviction pursuant to the same rules that apply to detainee/felons in local custody.
Ordinarily, the measure of maximum entitlement to conduct credits would be that contained in section 4019. However, section 4019 is subject to the maximum credit limitations of section 2933.1. It provides that "the maximum credit that may be earned against a period of confinement in [local custody], following arrest and prior to placement in the custody of the [CDC], shall not exceed 15 percent of the actual period of confinement for any person" "convicted of a felony offense listed in Section 667.5" committed after the September 21, 1994, operative date of the section. (§ 2933.1, subds.(c), (a) and (d).) Defendant was convicted of second degree robbery, committed November 25, 1995, a felony offense that is within the "any robbery" provision of section 667.5, subdivision (c)(9).
This leads to the final question whether it is the CDC which should determine the actual conduct credits earned.[8]

III
"Penal Code section 2900.5 imposes on the sentencing court the obligation to determine the number of days of custody and, in those cases to which it expressly applies, conduct credit to which the defendant is entitled, and to enter the credits on the abstract of judgment." (People v. Sage, supra, 26 Cal.3d at pp. 508-509, 165 Cal.Rptr. 280, 611 P.2d 874.) Section 2900.5, subdivision (a), expressly provides for conduct credits only for "days credited to the period of confinement pursuant to Section 4019
However, sections 4019 and 2933.1 do not expressly apply to this case since they do not by their terms apply to time spent in prison. Rather, they apply only by virtue of principles of equal protection. For these reasons section 2900.5 does not apply and we are free to fashion a suitable remedy. In this circumstance it is appropriate to assign the task of determining the actual conduct credits earned pursuant to the standards of section 4019, subject to the limitations of section 2933.1, to the body which possesses the records of defendant's conduct in prison, the CDC.

DISPOSITION
The case is remanded to the trial court with directions to amend the abstract of judgment to state that defendant is entitled to conduct credits for the time spent in the state prison prior to the reversal of the judgment of conviction measured by the standards set forth in section 4019, subject to the maximum credit limitations of section 2933.1,[9] but the Department of Corrections shall determine, based upon defendant's performance in prison, the actual *539 credits earned during such confinement. In all other respects the judgment is affirmed.
I concur: HULL, J.
KOLKEY, J.
I respectfully dissent. By treating defendant's four-and-one-half years of postsentence time as presentence time, the majority concludes that equal protection principles require it to apply to defendant the distinct formula for presentence conduct credits afforded under a concededly inapplicable statute (Pen.Code, § 4019),[1] as limited by an inapplicable statutory subdivision (§ 2933.1, subd. (c)).
This treatment of postsentence time, which is served pursuant to an invalidated conviction, as presentence time, despite a defendant's reconviction and resentencing for the same offense,
 is not required by the only statute that addresses the subject, which treats the postsentence time served pursuant to the subsequently invalidated judgment as part of defendant's service under the new sentence (§ 2900.1);
 will skew and conflate the disparate goals of the pre- and postsentence credit systems (People v. Buckhalter (2001) 26 Cal.4th 20, 36, 108 Cal. Rptr.2d 625, 25 P.3d 1103) (hereinafter Buckhalter);

 will upset the application of the Three Strikes law since that law does not limit presentence conduct credits (People v. Thomas (1999) 21 Cal.4th 1122, 1125, 90 Cal.Rptr.2d 642, 988 P.2d 563), but does limit the postsentence conduct credits awarded to a defendant (§§ 667, subd. (c)(5), 1170.12, subd. (a)(5)); and
 may ironically give rise to its own equal protection violations in many cases since giving a defendant the benefit of presentence conduct credits for a lengthy period of postconviction custody will result in that defendant serving a significantly different term than an identical defendant serving the exact same sentence for the exact same conviction.
On the other hand, if defendant's postsentence prison time prior to the invalidation of his conviction is treated as postsentence time under his new prison sentence, such treatment will
 comport with the defendant's understanding of the status of his prior postsentence custody at the time he served it;
 avoid conflating the disparate goals of the pre- and postsentence credit systems;
 conform with the treatment of such prior postsentence custody under section 2900.1;
 avoid untoward results contrary to the Three Strikes law; and
 comply with equal protection principles.
In short, what is wrong with treating what the defendant understood to be postconviction prison custody at the time he served it as postconviction custody?

A
In this case, after defendant successfully petitioned a federal court to invalidate his conviction for second degree robbery, he entered a plea of guilty to the same offense and was resentenced to 10 years in prison pursuant to the Three Strikes law. He now asks that his time in prison between his original sentencing and the invalidation of his conviction be afforded the *540 benefit of the more favorable formula for presentence conduct credits for detainees in local custody prior to sentencing (§ 4019),[2] rather than be subject to the more restrictive treatment of conduct credits required by the Three Strikes law for prison time. (Pen.Code, §§ 667, subd. (c)(5), 1170.12, subd. (a)(5)).[3]
The majority concludes that defendant is entitled to have his prison time prior to the invalidation of his conviction treated as presentence time. Of course, as the majority concedes, no statute provides for presentence conduct credits under these circumstances (maj. opn. at p. 533), and thus the majority is reduced to applying to defendant's postsentence time the measure for presentence conduct credits for detainees in local custody pursuant to section 4019, as limited by section 2933.1, subdivision (c), which limits the maximum credits for local custody time for defendants convicted of a violent felony, as here.
The linchpin of the majority opinion is its conclusion that "we view defendant's time in prison prior to the invalidation of the judgment of conviction as time spent in custody prior to conviction" (maj. opn. at p. 535) because "[w]e are directed by statute to view defendant's time in prison custody prior to the invalidation of the judgment of conviction as if he had not been convicted." (Maj. opn. at p. 534.)
The statutory directive to which the majority refers, based on sections 1262 and 1180, does not go so far. Section 1262 provides that "[i]f a judgment against the defendant is reversed, such reversal shall be deemed an order for a new trial ...," and section 1180 provides that "[t]he granting of a new trial places the parties in the same position as if no trial had been had."
But placing a defendant, upon the granting of a new trial, in the same position as if no trial had been had, says nothing about how his prior prison time should be treated upon reconviction of the same offense. Instead, the purpose of these statutes is to entitle "a criminal defendant ..., upon retrial, to the rights of the federal and state Constitutions which attach at the trial stage of criminal proceedings." (People v. Hogue (1991) 228 Cal.App.3d 1500, 1505, 279 Cal.Rptr. 647.)
But the issue of a defendant's conduct credits does not arise upon the granting of a new trial. "Conduct credits do not become an issue until and unless a person is convicted." (People v. Sylvester (1997) 58 Cal.App.4th 1493, 1496, 68 Cal.Rptr.2d 716.) Thus, placing the parties, upon the granting of a new trial, in the same position as if no trial had been held says nothing about the application of sentencing credits following conviction. Indeed, statutes that govern presentence credits are triggered by, and often dependent upon the nature of, the defendant's subsequent *541 conviction. For instance, section 2933.1, subdivision (c)the very statute that the majority applies herelimits presentence conduct credits to 15 percent of the period of presentence confinement with respect to defendants subsequently convicted of a violent felony, such as the offense here. And section 2933.2, subdivision (c), bars a defendant subsequently convicted of murder from receiving any presentence conduct credits. In short, placing a party in the same position as if no trial had been held, as required under section 1180, does not address the party's status after the trial is heldwhich is when a defendant's rights to sentencing credits arise.[4]
One statute, however, specifically addresses the status of a defendant's prison time where it is served pursuant to a subsequently invalidated judgment. Section 2900.1 provides: "Where a defendant has served any portion of his sentence under a commitment based upon a judgment which judgment is subsequently declared invalid or which is modified during the term of imprisonment, such time shall be credited upon any subsequent sentence he may receive upon a new commitment for the same criminal act or acts."
This statute overturned early California Supreme Court authority that suggested that because a reversed judgment was void, the period of imprisonment served under that judgment was lost and could not be counted as part of the defendant's subsequent sentence upon reconviction. (In re Fritz (1918) 179 Cal. 415, 177 P. 157; People v. Chew (1985) 172 Cal.App.3d 45, 51, 217 Cal.Rptr. 805, disapproved on another ground in Buckhalter, supra, 26 Cal.4th at p. 40, 108 Cal.Rptr.2d 625, 25 P.3d 1103.) Section 2900.1 remedied this inequity by crediting the defendant with the time served under the invalidated judgment for purposes of the subsequent sentence. But the statute does not characterize the defendant's time in prison prior to the invalidation of his or her judgment as presentence time, but only as time deemed served under the new sentence.
The California Supreme Court's recent decision in Buckhalter, supra, 26 Cal.4th 20, 108 Cal.Rptr.2d 625, 25 P.3d 1103, bolsters this conclusion. In Buckhalter, supra, the state high court stated: "Section 2900.1 thus speaks in terms of a prison sentence already in progress, and, in contrast with section 2900.5, it omits reference to presentence good behavior credits under section 4019. The implication is that once the defendant is committed to prison, his custody is thereafter considered service of his sentence, and a remand with respect to a sentence the defendant is already serving does not render him eligible for credits of the presentence kind." (26 Cal.4th at p. 33, 108 Cal.Rptr.2d 625, 25 P.3d 1103, italics added.)
Admittedly, the state high court's decision in Buckhalter only addressed section 2900.1 in the context of "a limited appellate remand for correction of sentencing errors," holding that "a convicted felon once sentenced, committed, and delivered to prison is not restored to presentence status, for purposes of the sentence-credit statutes ...." (26 Cal.4th at p. 23, 108 Cal.Rptr.2d 625, 25 P.3d 1103.)[5] But *542 Buckhalter's limited ruling cannot alter that part of the court's interpretation of the clause in section 2900.1which remains constant regardless of whether the judgment is invalidated or only modified that once committed to prison, a defendant's "custody is thereafter considered service of his sentence" upon a new commitment for the same criminal act. (26 Cal.4th at p. 33, 108 Cal.Rptr.2d 625, 25 P.3d 1103.)
In the face of a specific statute on point (§ 2900.1), sections 1262 and 1180which address the rights of the parties upon the granting of a new trialcannot govern the treatment of previously served prison time following reconviction for the same offense. Under settled rules of statutory construction, "[a] specific provision relating to a particular subject will govern in respect to that subject, as against a general provision, although the latter, standing alone, would be broad enough to include the subject to which the more particular provision relates." (Rose v. State of California (1942) 19 Cal.2d 713, 723-724, 123 P.2d 505.)
The majority nonetheless argues that "[w]hile section 1180 plainly includes trial proceedings, it beggars belief that a defendant who is by law placed in the same position as if no trial had been had may be treated differently on reconviction by virtue of the sentence served pursuant to the very conviction that had been invalidated ...." (Maj. opn. at p. 534.) The majority concludes that "the dissent would depart from the plain words of section 1180 on the grounds it does not apply to conduct credits and should be judged ... as if defendant was not placed in the same position as if no trial had been had." (Maj. opn. at p. 536.) But it is hardly a departure from the plain words of section 1180a statute whose language does not specifically address the issue of prior prison timeto rely instead on a narrowly drawn statute (section 2900.1), which specifically addresses the subject of the treatment of prison time pursuant to an invalidated judgment. That is what rules of statutory construction call for.
The flaw in the majority's analysis is that it relies on section 1180 to the exclusion of the statute that specifically addresses the treatment of prison time pursuant to an invalidated judgment, reads section 1180 overly literally to deem that no trial was ever held (instead of merely placing defendant in the same position at the time of the retrial as if no trial had been held), and neglects the rule of statutory construction that provides that when a specific statute relates to a particular subject, it prevails over the general one that does not. Indeed, under the majority's literal approach to section 1180, if no prior trial is deemed to have been held upon the granting of a new trial, then no testimony from the prior trial could ever be used at the new trial because the defendant must be treated as if no trial had been had. Of course, that is not the case. (Evid.Code, § 1291; People v. Ramos (1997) 15 Cal.4th 1133, 1164, 64 Cal. Rptr.2d 892, 938 P.2d 950.) And under the majority's approach, if no trial is deemed to have been had, then defendant could not have been in prison, since that occurs following a trial. But section 1180 cannot be taken to such an extreme so as to rewrite history. And in any event, under settled rules of statutory construction, it cannot be broadly interpreted to cover a subject that is specifically addressed by another statute.
Furthermore, even if the directive under section 1180 could be theoretically read to recharacterize defendant's postconviction custody as presentence custody, a fundamental rule of statutory construction is that "[t]he words of the statute must be *543 construed, in context, keeping in mind the statutory purpose ...." (Dyna-Med, Inc. v. Fair Employment & Housing Com. (1987) 43 Cal.3d 1379, 1387, 241 Cal.Rptr. 67, 743 P.2d 1323.) As noted, section 1180 is intended to grant a criminal defendant, upon retrial, the same constitutional rights that attach at the trial stage of a criminal proceeding. (People v. Hogue, supra, 228 Cal.App.3d at p. 1505, 279 Cal.Rptr. 647.) A general statute (§ 1180) should not be taken to an extreme to cover a subject outside its purpose, which a more narrow statute (§ 2900.1) specifically addresses. "Stated in another way where one provision of a statute treats specially and solely of a matter, it prevails over other provisions which make only incidental reference thereto because the attention of the Legislature was directed to the particular matter." (People v. Moroney (1944) 24 Cal.2d 638, 644, 150 P.2d 888.) Thus, defendant's service of his prior prison term in this case should be deemed part of his new sentence in accordance with section 2900.1, not as presentence custody as a purportedly logical deduction from the general language of section 1180.
The majority nonetheless argues that "[s]ection 2900.1 contains two clauses, one dealing with the invalidation of a conviction, at issue here, and the other with the modification of a sentence, at issue in Buckhalter," but that the "dissent misreads section 2900.1 by [con]fusing its two separate clauses." (Maj. opn. at p. 537.) To the contrary, the relevant clause "such time shall be credited upon any subsequent sentence he may receive upon a new commitment for the same criminal act or acts"applies regardless of whether the judgment is declared invalid or is modified. Again, the statute provides: "Where a defendant has served any portion of his sentence under a commitment based upon a judgment which judgment is subsequently declared invalid or which is modified during the term of imprisonment, such time shall be credited upon any subsequent sentence he may receive upon a new commitment for the same criminal act or acts." (§ 2900.1, italics added.)
The meaning of the italicized clause cannot vary based on whether the judgment is invalidated or the sentence modified. In either case, the portion of the prison sentence served "under a commitment based upon a judgment," which is subsequently invalidated or modified, is "credited upon any subsequent sentence ... upon a new commitment for the same criminal act or acts." (§ 2900.1) In either case, "[defendant's] custody is thereafter considered service of his sentence." (Buckhalter, supra, 26 Cal.4th at p. 33, 108 Cal.Rptr.2d 625, 25 P.3d 1103.)
Accordingly, in light of section 2900.1, which addresses the subject of prison time served pursuant to an invalidated judgment, there is no basis to use section 1180 to treat defendant's postsentence prison time as presentence time. Instead, it should be treated as part of his service of his new sentence upon his resentencing for the same criminal act. (See Buckhalter, supra, 26 Cal.4th at p. 23, 108 Cal.Rptr.2d 625, 25 P.3d 1103.)

B
Once it is conceded that upon his reconviction, section 2900.1 applies to the status of defendant's prior prison time, the proper analysis for this case easily follows. Section 2900.1 credits defendant's new sentence with the prison time served pursuant to the subsequently invalidated judgment, but affords him no conduct credits.
Unquestionably, a serious equal protection violation would arise if the defendant here received no conduct credits for the time that he served in state prison pursuant to his invalidated judgment. (See People *544 v. Sage (1980) 26 Cal.3d 498, 165 Cal. Rptr. 280, 611 P.2d 874.) After all, another defendant serving the same sentence in state prison pursuant to the Three Strikes law would be eligible for conduct credits of up to one-fifth of his total prison sentence pursuant to the Three Strikes law (§§ 667, subd. (c)(5), 1170.12, subd. (a)(5)), but could only accrue worktime credits of up to 15 percent since the current offense was a violent felony (§ 2933.1, subd. (a)[6]). The only difference between the similarly situated defendants would be that the first defendant appealed his erroneous judgment, while the other defendant's judgment was correct in the first instance. The first defendant cannot be penalized because he successfully exercised his right to petition the courts. (Cf. Pacific Gas & Electric Co. v. Bear Stearns & Co. (1990) 50 Cal.3d 1118, 1132-1135, 270 Cal.Rptr. 1, 791 P.2d 587.)
But this equal protection violation can be remedied by affording the defendant here the same postsentence conduct credits afforded the similarly situated defendant, namely, conduct credits of up to one-fifth of his total prison term but no more than 15 percent of worktime credits. "`The essence of equity jurisdiction has been the power of the Chancellor to do equity and to mould each decree to the necessities of the particular case.'" (Swann v. Charlotte-Mecklenburg Bd. of Edu. (1971) 402 U.S. 1, 15, 91 S.Ct. 1267, 1276, 28 L.Ed.2d 554, 566.) "As with any equity case, the nature of the violation determines the scope of the remedy." (Id. at p. 16, 91 S.Ct. at 1276, 28 L.Ed.2d at p. 567.)
In this case, the nature of the equal protection violation is the failure of the applicable statute, section 2900.1, to afford defendant any conduct credits for his postconviction custody under the former judgment when a similarly situated defendant would receive such credits for the same prison time. The nature of the violation thus determines the scope of the remedy: The defendant should be eligible for conduct credits for the prison time served in accordance with the invalidated judgment, which are commensurate with the conduct credits afforded for prison time served under the same sentence for the same offense.
This equal protection remedy has the added virtue of treating postconviction prison time prior to the invalidation of defendant's judgmentwhich the defendant understood to be postconviction time when he served itas (amazingly) postconviction time.

C
The majority opinion nonetheless suggests that equal protection principles require that the defendant "be awarded conduct credits for the time served in prison prior to invalidation of his conviction pursuant to the same rules that apply to detainee/felons in local custody." (Maj. opn. at p. 538.)
But equal protection principles do not require that conduct credits available for presentence time for a detainee in a local facility be applied to state prison time served after the detainee has been convictedeven where the conviction is invalidated and the defendant is reconvicted and resentenced for the same offense. The presentence custody time of a detainee who has never been convicted is not the same as the postsentence custody time of a defendant who has been convicted, invalidates *545 the conviction, and is then reconvicted and resentenced for the same offense. In fact, the California Supreme Court explained in Buckhalter, supra, 26 Cal.4th at page 36, 108 Cal.Rptr.2d 625, 25 P.3d 1103, that the pre- and postsentence credit systems serve disparate goals and target persons who are not similarly situated:
"[T]he pre- and postsentence credit systems serve disparate goals and target persons who are not similarly situated. The presentence credit scheme, section 4019, focuses primarily on encouraging minimal cooperation and good behavior by persons temporarily detained in local custody before they are convicted, sentenced, and committed on felony charges. By contrast, the worktime credit scheme for persons serving prison terms emphasizes penological considerations, including the extent to which certain classes of prisoners, but not others, deserve or might benefit from incentives to shorten their terms through participation in rehabilitative work, education and training programs operated by the Department of Corrections." (Buckhalter, supra, 26 Cal.4th at p. 36, 108 Cal.Rptr.2d 625, 25 P.3d 1103.)
Those incentives were at work at the time the defendant served his postconviction prison confinement here: At the time he served his prison time prior to the invalidation of his conviction, he understood he was operating under the restrictions of the Three Strikes law. Retroactively recharacterizing that time as presentence custody furthers neither the incentives nor policies embodied in the pre- and postsentence credit systems. Nonetheless, the majority would retroactively treat the postconviction time as the equivalent of presentence time. This skews and conflates the disparate goals of the pre- and postsentence credit systems.
Moreover, notwithstanding the fact that "the nature of the violation determines the scope of the remedy" (Swann v. Charlotte-Mecklenburg Bd. of Edu., supra, 402 U.S. at p. 16, 91 S.Ct. at 1276, 28 L.Ed.2d at p. 567), the majority's remedy of granting presentence conduct credits for postsentence custody goes well beyond the scope of the violation. The majority can only change the nature of the violation to be remedied by retroactively characterizing postsentence custodywhich defendant understood to be postsentence custody when he served itas presentence custody. But the Equal Protection Clause's principle of treating similarly situated persons equally would be turned on its head if it had to treat, as equal, dissimilar events that are only made similar by retroactively recharacterizing one of them.
Nor does People v. Sage, supra, 26 Cal.3d 498, 165 Cal.Rptr. 280, 611 P.2d 874, cited by the majority, require that defendant's postsentence confinement be treated as presentence custody. There, under a former version of section 4019, a pretrial detainee eventually convicted of a misdemeanor and sentenced to county jail received conduct credits against that sentence for presentence jail time, but a felon did not. Instead, that felon was only eligible for conduct credits for prison time served subsequent to conviction. The Supreme Court ruled that "[i]t is the distinction between the detainee/felon and the felon who serves no presentence time [because he makes bail or is released on his own recognizance] that raises equal protection problems." (26 Cal.3d at p. 507, 165 Cal.Rptr. 280, 611 P.2d 874.)
But in this case, all felons are eligible for presentence conduct credit for their presentence custody in local facilities prior to their initial conviction. Surely, we can distinguish between the limited period of preconviction custody (which is subject to *546 conduct credits under section 4019, as limited from time to time by other statutes) and the more lengthy postconviction period in state prison during which conduct credits are severely restricted under the Three Strikes law and other statutes, but can in other circumstances be more generous.
The majority states that it "perceive[s] no material distinction between this case and Sage." It reasons that in Sage "the felon was denied conduct credits for time spent in jail prior to conviction," and here "the felon is denied conduct credits for time spent in prison prior to a reconviction." (Maj. opn. at p. 536.) But a defendant's postconviction imprisonment pursuant to an invalidated judgment is not indistinguishable from time spent in jail prior to conviction since at the very time the former imprisonment was being served it was understood to be time spent in prison after conviction. If that defendant is reconvicted and resentenced for the same offense, only legal fictions, not legal reality, would treat what was postconviction custody at the time it was served as preconviction custody.
Finally, the majority's equal protection remedy ironically gives rise to potential equal protection violations: If a defendant's postsentence time, served pursuant to an invalidated judgment, is treated as presentence time upon reconviction, such an application would treat similarly situated defendants differentlyone who received an error-free judgment at the outset and the other who successfully appealed, was retried, and then received the same judgment as the first defendant. The second defendant would be afforded presentence conduct credits for a potentially lengthy period of his or her postsentence custody that the first defendant would not. Although there is not a great difference between the two defendants in this case because defendant's violent felony here limits both his postsentence and presentence conduct credits,[7] in other cases, the treatment of postsentence custody as presentence time will cause great disparities in conduct credits that can reduce prison terms by years because of the different formulas for pre- and postsentence conduct credits.

D
Accordingly, a defendant's postsentence time, served pursuant to an invalidated judgment, should not be treated as presentence time upon that defendant's reconviction and resentencing for the same offense. Such treatment is not mandated by statute (which treats the prior postsentence custody as part of the defendant's service of the new sentence), is at variance with the defendant's understanding of the status of his prior postconviction custody at the time he served it, will skew and conflate the disparate goals of the pre- and postsentence credit systems, will upset the application of the Three Strikes law (which restricts postsentence but not presentence conduct credits), and may give rise to its own equal protection violations.
As Justice Cardozo once observed, "The soundness of a conclusion may not infrequently be tested by its consequences." (Ostrowe v. Lee (1931) 256 N.Y. 36, 40, 175 N.E. 505.) It is for that reason that I dissent. Instead, the better approach *547 would be to take the bold step of treating postsentence time aspostsentence time.[8]
NOTES
[1]  Further references to a section are to the Penal Code unless otherwise stated.
[2]  At defendant's request, we have taken judicial notice of our opinion in case No. C023570 and the California Supreme Court's order denying review. (Evid.Code, §§ 452, subd. (d)(1), 459, subd. (a).)
[3]  At sentencing, defendant asked the trial court to award "either fifty percent" or "minimally ... one-third" credit for his time in state prison. The court responded: "The Department of Corrections and/or a higher authority will probably tell me what is correct." Later, the court reiterated, "I presume whatever I say the Department of Corrections will send it back with whatever they feel is the law." We conclude that defendant adequately preserved this issue on appeal and reject the People's claim the issue has been waived.
[4]  The dissent also would limit the reach of section 1180 by reference to cases involving the superior law of the federal constitution, cases which are not in point since, as we later show, section 1180 is applied in this case to implement a constitutional provision.
[5]  Section 4019 expressly applies only to the determination of the credits for time served when "a prisoner is confined in or committed to a county jail, industrial farm, or road camp, or any city jail, industrial farm, or road camp ...." (§ 4019, subds. (a)(1) through (a)(4).)
[6]  Section 2900.1, in relevant part, provides: "Where a defendant has served any portion of his sentence under a commitment based upon a judgment which judgment is subsequently declared invalid ... such time shall be credited upon any subsequent sentence he may receive upon a new commitment for the same criminal act or acts." (§ 2900.1; see In re Helpman (1968) 267 Cal.App.2d 307, 311, 72 Cal.Rptr. 753.) We later consider the application of the separate clause in section 2900.1 which applies to the modification of a sentence.

In addition, section 2900.5, subdivision (a), provides: "In all felony ... convictions, either by plea or by verdict, when the defendant has been in custody, including ... any time spent in a jail, camp, work furlough facility, halfway house, rehabilitation facility, hospital, prison, juvenile detention facility, or similar residential institution, all days of custody of the defendant ..., including days credited to the period of confinement pursuant to Section 4019, shall be credited upon his or her term of imprisonment ...." (Italics added.)
[7]  The court recognized the distinction in "expressing no views" whether 4019 credits should be awarded in the analogous situation for "confinement [in prison] between the original sentencing and a resentencing that followed the trial court's recall, within 120 days, of the commitment ...." (26 Cal.4th at p. 40, fn. 10, 108 Cal.Rptr.2d 625, 25 P.3d 1103.)
[8]  At oral argument, the defendant argued the determination of credits should be made by the trial judge pursuant to section 4019. Although the argument comes late, we give an answer as a necessary component of the resolution assessed in the opinion.
[9]  The trial court shall also apply the limitations of section 2933.1 to any credits previously awarded for the actual time spent in local custody. Section 2933.1 was apparently not raised in the trial court. However, to the extent that unauthorized credit was awarded it must be corrected when brought to the attention of the court. (People v. Serrato (1973) 9 Cal.3d 753, 764, 109 Cal.Rptr. 65, 512 P.2d 289; People v. Walkkein (1993) 14 Cal.App.4th 1401, 1411, 18 Cal.Rptr.2d 383.)
[1]  Unless otherwise designated, all further statutory references are to the Penal Code.
[2]  Section 4019 provides for 2 conduct credits for every 4 days of presentence custody for persons detained in specifically enumerated local facilities, including county or city jails, industrial farms, or road camps. (§ 4019, subds.(a)(4), (b), (c), (0.)
[3]  A defendant serving a sentence under the Three Strikes law cannot earn prison conduct credits exceeding one-fifth of his total term of imprisonment. The Three Strikes law provides that "[n]otwithstanding any other provision of law, if a defendant has been convicted of a felony and it has been pled and proved that the defendant has one or more prior felony convictions, ... the court shall adhere to each of the following: [¶] ... [¶] (5) The total amount of credits awarded pursuant to Article 2.5 (commencing with Section 2930) [dealing with credits for a term in prison] ... shall not exceed one-fifth of the total term of imprisonment imposed and shall not accrue until the defendant is physically placed in the state prison." (§§ 1170.12, subd. (a)(5), 667, subd. (c)(5).)
[4]  The majority argues that "[t]he dissent engages a nonsequitur in seeking policy support by reference to sections which tie presentence credits to a subsequent not a prior conviction." (Maj. opn. at p. 534.) But the point of citing such sections is not to seek "policy support," but to illustrate that the right to sentencing credits does not arise upon the granting of a new trial, but is only triggered upon conviction, which is outside the purpose of section 1180.
[5]  The majority's contention that the dissent has "misread[]" or overlooked this point (maj. opn. at p. 537) is inexplicable.
[6]  Section 2933.1, subdivision (a), provides: "Notwithstanding any other law, any person who is convicted of a felony offense listed in Section 667.5 shall accrue no more than 15 percent of worktime credit, as defined in Section 2933."
[7]  As noted, section 2933.1, which the majority applies here, limits presentence conduct credits to 15 percent of the actual period of confinement (§ 2933.1, subd. (c)) and postsentence worktime credits to 15 percent (§ 2933.1, subd. (a)).
[8]  Admittedly, there is a separate period of time prior to defendant's resentencing which may not constitute postsentence confinement (and which the defendant would not have understood to be postsentence custody when he served it): the time between the invalidation of the judgment and defendant's resentencing. But defendant does not raise this distinction in this case and gives us no information concerning the circumstances of his detention during that period. Nor does the majority address this period in its decision. In the absence of any argument making this distinction and without a presentation of the relevant facts, I decline to address this issue. I note that the California Supreme Court has also not yet considered "the proper credit treatment of one who spends time in custody after his convictions have been reversed on appeal." (People v. Buckhalter, supra, 26 Cal.4th at pp. 40-41, fn. 10, 108 Cal.Rptr.2d 625, 25 P.3d 1103.)
