Where the offense is a continuing crime, presentence credits are calculated according to the statute in effect at the time the offense was completed. Appellant pled no contest to stalking (Pen. Code, § 646.9, subd. (b).) According to the complaint, he stalked the victim between July 23, 2009, and May 18, 2012. During this period, Penal Code section 4019 (which governs calculation of presentence conduct credits) was amended several times. On appeal, the court requested briefing as to whether the less favorable calculation rate of the 2011 amendment can apply to appellant without violating state and federal ex post facto provisions. Held: Custody credits modified. Application of an amended law to a continuing offense where the offending acts occurred in part before and in part after the amendments effective date does not violate ex post facto principles. Here, the court found that stalking is a continuous offense. The stalking statute defines the offense as one where the defendant repeatedly follows, etc., another person. A continuous course of conduct is required to effect the crime. The primary purpose of ex post facto provisions is to ensure that legislative acts give fair warning of their effect. Although appellant’s conduct straddled the effective dates of the various amendments to the credit statute, the version in effect at the time the stalking ceased was applicable to the calculation of credits. This version provides for a two-for-two accrual method whereby defendant receives an even number of conduct credits for an odd number of actual days in custody. There is no ex post facto violation with application of this version because appellant had fair warning that if his stalking persisted, he would potentially serve a longer prison term due to a decrease in the presentence custody credit accrual rate. Accordingly, appellant was entitled to 213 days of actual custody credit plus 212 days of conduct credit.