Converting dates from different bases are almost a major problem for programs in Iran and other Islamic countries, there are some special points that makes such algorithms too hard to understand.
I had such a problem when I want to write a program for project management.
These programs can convert dates, please note that I have not written the converter algorithm, I just used existing algorithms.
The second converter uses a very very powerful algorithm and there are lots of modules for other date calculations, try it. ( I am trying to remember the writers name and site address ... )