Backport PR #38331 on branch 1.2.x (BUG: first("1M") returning two months when first day is last day of month)
Backport PR #38331: BUG: first("1M") returning two months when first day is last day of month