This is a serious non-trivial problem and really depends on what exactly you want to do with these dates. For example, we used only the current (Gregorian) calendar from 1582. Before that, it was the Julian calendar, and before that the old Roman calendar. Even worse, this information is valid only for Western Europe (and culturally-related areas). Therefore, if you are hoping to get something that will give you the correct accepted dates for historical events with a little simple math, you will be in great disappointment.
If you just want to run the Gregorian calendar in the opposite direction, I believe this is doable. However, there is still an error, in which case it matters. Material from Wikipedia:
By the times of thousands of years, the Gregorian calendar lags behind the seasons because the Earth's rotation slows down every day a little longer (see tidal acceleration and leap per second), while the year maintains a more uniform duration
source share