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
Claus Tøndering - firstname.lastname@example.org (Please include the word "calendar" in the subject line.)