Cal. Civ. Code § 3529
That which ought to have been done is to be regarded as done, in favor of a person to whom, and against a person from whom, performance is due.