1,358. Who Need Not Fast
Hilchos Taaniyos 1:8
Pregnant women, nursing mothers and children (under the age of bar and bas mitzvah) are not required to fast on fasts that are declared because of communal troubles. On these fasts, even though one may not eat by day, it is permitted on the preceding night (which is part of the same day in the Jewish calendar). The exception to this is fasts that are called because of rain, which will be explained. Whenever one is permitted to eat on the night preceding a fast, whether it is a communal or a private fast, one may eat until dawn so long as he does not sleep. If he goes to sleep, he may not eat when wakes up. Hilchos Taaniyos 1:9
Just as the community fasts because of troubles, each individual person should likewise fast because of distress. When a loved one is sick, lost in the desert or imprisoned, one should fast for this person, pray that he receive mercy, and recite “aneinu” in each Shemoneh Esrei of the day. One does not fast for such a reason on Shabbos, yom tov, Rosh Chodesh, Chanukah or Purim.