The trial court research attorneys s are now happier!  No longer can an amended pleading be filed the morning before the demurrer hearing!  As of 2018, amended Code of Civil Procedure §472 now provides:

(a) A party may amend its pleading once without leave of the court at any time before the answer, demurrer, or motion to strike is filed, or after a demurrer or motion to strike is filed but before the demurrer or motion to strike is heard if the amended pleading is filed and served no later than the date for filing an opposition to the demurrer or motion to strike. A party may amend the pleading after the date for filing an opposition to the demurrer or motion to strike, upon stipulation by the parties. The time for responding to an amended pleading shall be computed from the date of service of the amended pleading.  (This rule sunsets January 1, 2021)