=ARRAYFORMULA(REGEXREPLACE(TO_TEXT(QUERY({TEXT(TRANSPOSE(D1:1), "m♦mmmm yyyy"),
TRANSPOSE(D2:2)-IF(MOD(ROW(INDIRECT("A1:A"&COLUMNS(D1:1))), 4)=0,
DAYS(EOMONTH(TRANSPOSE(D1:1), 0), TRANSPOSE(D1:1))/7*TRANSPOSE(D2:2), )+
QUERY({""; IF(MOD(ROW(INDIRECT("A1:A"&COLUMNS(D1:1))),4)=0,
DAYS(EOMONTH(TRANSPOSE(D1:1), 0), TRANSPOSE(D1:1))/7*TRANSPOSE(D2:2), )},
"limit "&COLUMNS(D1:1), 0)},
"select Col1,sum(Col2) where not Col2 = 0 group by Col1 label sum(Col2)''", 0)),
"(.+)♦", ))
FIX:
=ARRAYFORMULA(TRANSPOSE(QUERY({REGEXREPLACE(TO_TEXT(QUERY({TEXT(TRANSPOSE(D1:1), "m♦mmmm yyyy"),
TRANSPOSE(D2:2)-IF(MOD(ROW(INDIRECT("A1:A"&COLUMNS(D1:1))), 4)=0,
DAYS(EOMONTH(TRANSPOSE(D1:1), 0), TRANSPOSE(D1:1))/7*TRANSPOSE(D2:2), )+
QUERY({""; IF(MOD(ROW(INDIRECT("A1:A"&COLUMNS(D1:1))),4)=0,
DAYS(EOMONTH(TRANSPOSE(D1:1), 0), TRANSPOSE(D1:1))/7*TRANSPOSE(D2:2), )},
"limit "&COLUMNS(D1:1), 0)},
"select Col1,sum(Col2) where not Col2 = 0 group by Col1 label sum(Col2)''", 0)),
"(.+)♦", ),
IF(LEN(QUERY(REGEXREPLACE(TO_TEXT(QUERY({TEXT(TRANSPOSE(D1:1), "m♦mmmm yyyy"),
TRANSPOSE(D2:2)-IF(MOD(ROW(INDIRECT("A1:A"&COLUMNS(D1:1))), 4)=0,
DAYS(EOMONTH(TRANSPOSE(D1:1), 0), TRANSPOSE(D1:1))/7*TRANSPOSE(D2:2), )+
QUERY({""; IF(MOD(ROW(INDIRECT("A1:A"&COLUMNS(D1:1))),4)=0,
DAYS(EOMONTH(TRANSPOSE(D1:1), 0), TRANSPOSE(D1:1))/7*TRANSPOSE(D2:2), )},
"limit "&COLUMNS(D1:1), 0)},
"select Col1,sum(Col2) where not Col2 = 0 group by Col1 label sum(Col2)''", 0)),
"(.+)♦", ),"select Col1",0)), MONTH(LEFT(
QUERY(REGEXREPLACE(TO_TEXT(QUERY({TEXT(TRANSPOSE(D1:1), "m♦mmmm yyyy"),
TRANSPOSE(D2:2)-IF(MOD(ROW(INDIRECT("A1:A"&COLUMNS(D1:1))), 4)=0,
DAYS(EOMONTH(TRANSPOSE(D1:1), 0), TRANSPOSE(D1:1))/7*TRANSPOSE(D2:2), )+
QUERY({""; IF(MOD(ROW(INDIRECT("A1:A"&COLUMNS(D1:1))),4)=0,
DAYS(EOMONTH(TRANSPOSE(D1:1), 0), TRANSPOSE(D1:1))/7*TRANSPOSE(D2:2), )},
"limit "&COLUMNS(D1:1), 0)},
"select Col1,sum(Col2) where not Col2 = 0 group by Col1 label sum(Col2)''", 0)),
"(.+)♦", ),"select Col1", 0), 3)&1)&RIGHT(
QUERY(REGEXREPLACE(TO_TEXT(QUERY({TEXT(TRANSPOSE(D1:1), "m♦mmmm yyyy"),
TRANSPOSE(D2:2)-IF(MOD(ROW(INDIRECT("A1:A"&COLUMNS(D1:1))), 4)=0,
DAYS(EOMONTH(TRANSPOSE(D1:1), 0), TRANSPOSE(D1:1))/7*TRANSPOSE(D2:2), )+
QUERY({""; IF(MOD(ROW(INDIRECT("A1:A"&COLUMNS(D1:1))),4)=0,
DAYS(EOMONTH(TRANSPOSE(D1:1), 0), TRANSPOSE(D1:1))/7*TRANSPOSE(D2:2), )},
"limit "&COLUMNS(D1:1), 0)},
"select Col1,sum(Col2) where not Col2 = 0 group by Col1 label sum(Col2)''", 0)),
"(.+)♦", ),"select Col1", 0), 4), )*1},
"select Col1,Col2 order by Col3")))