Islamic Sharia takes unavoidable factors for the benefit of Muslims considering them as excuses for relieving any hardship that may ensue. Thus, menstruation is canonically recognized to be a reason for many a concession that Muslim women have.

Answering this question, Sheikh MuhammadSalih Al-Munajjid, a prominent Saudi lecturer and author said:

If a woman has to fast for two consecutive months, and her period comes, she has to stop fasting, then complete her fast, and then make up the fasting she missed during her period. There is a scholarly consensus on this issue.

Imam Ibn Qudamah (may Allah have mercy on him) said: Scholars have unanimously agreed that if a woman, who is fasting two consecutive months, gets her period before completing that fast, she has to make up those days when she becomes ritually pure, because menstruation is something that cannot be avoided during those two months unless that fast is delayed until the woman reaches menopause. However, there is a risk that she may not be able to do the fast then. (Al-Mughni. 8/21)