actully we have two kinds of hijir date
1: Hijri Qamari the year is now 1439, this date is used most in arabic countries like saudi arabia;
2: Hijri shamsi which the year is now 1396, this date is used in countries like afghanistan, IRAN which some month has 31 days Like.
Example the 2nd month in hijri shamsi calendar has 31 days.
if you google for 2nd month year 1396 in hijri shamsi calendar you will find it it 31 days.
the code your write is for hijri qamari not for the hijri shamsi
thanks for spending you valuable time on solving this quesion