Designing calendars is one of the more difficult tasks that human beings have set themselves. You first needed to -determine- the lengths of the cycles of the solar year and the lunar month. This was not an easy task, and it was not achieved until well into recorded history.
The various cycles don't fit into each other particularly easily, either. With a solar year of just under 365.25 days, and a lunar month of just over 29.5 days, you aren't going to get it to come out even in the short run. You can stick with the sun and ignore the moon --- the solution of the Roman calendar fixed by Julius Cæsar. You can go with the moon, and leave the seasons to fall where they may --- as Muhammad, the desert-dwelling prophet of Islam, chose.
Or you can try to keep the moon and sun tied together, necessarily loosely. This requires a number of cumbersome kludges, as the Babylonians, the Jews, the Chinese, and the Christians who fixed the date of Easter all discovered. These calendars took a lot more thought than the ones that simply discarded one or the other heavenly lights, and rank among the most intricate and intriguing works of ancient astronomy.
This book contains a complete listing and description of the several solutions people have come up with to this seemingly intractable problem of arithmetic.