The Frequently Asked Questions about Calendars document is available here:
The Calendar FAQ includes a number of formulas for calculating various calendar values.
I have written a very simple implementation of these formulas in the C language. Rather than providing the most efficient code, the implementation intentionally follows the formulas very closely.
The code can be downloaded as a ZIP file
The photo below shows a tombstone located in the floor of the North Choir Aisle of Salisbury Cathedral in England. It illustrates how the new year hasn't always started on 1 January.
You rarely get to see a 3-digit year in actual use. The photo below shows the date in a document signed by the Holy Roman Emperor Charles III (a.k.a. Charles the Fat) on 2 April 883.
As described the Calendar FAQ, February had 30 days in Sweden in 1712.
The picture below shows two pages from a Swedish almanac from 1712.
Although a 30 February has indeed occurred in history, what about 31 February?