Fix inconsistent parsing of Durations with both months and years
#27610

Envek wants to merge Envek:fix_and_speed_up_duration_parsing into rails:master

We do not currently have an analysis of these two commits