#include const long frenchEpoch = 2375840; const double daysPerFrenchYear = 1460969.0 / 4000.0; // The names of the 5 (or 6) additional days at the end of the normal // calendar (that has 12 months of 30 days each, or 360 days) static const char * sansCulNames [] = { "Invalide", "Jour de la Vertu", "Jour du Genie", "Jour du Travail", "Jour de la Raison", "Jour des Recompenses", "Jour de la Revolution" }; // The names of the 12 months (coined by Fabre d'Eglantine) static const char * frenchMonthsNames [] = { "Invalide", "Vendemiaire", "Brumaire", "Frimaire", "Nivose", "Pluviose", "Ventose", "Germinal", "Floreal", "Prairial", "Messidor", "Thermidor", "Fructidor" }; long french2jul( int fd, int fm, int fy ) { // From Edward M. Reingold and Nachum Dershowitz - "Calendrical // Calculations: The Millennium Edition" (Cambridge University // Press, 2001) - page 238 // // Essentially, all the days before the given date are summed to the // Julian Day number corresponding to the first year of the French // Revolutionary Calendar. if (fy < 1) { throw std::domain_error("Before the French Revolution"); } long result = frenchEpoch - 1; result += 365 * --fy; result += fy / 4; result -= fy / 100; result += fy / 400; result -= fy / 4000; result += 30 * --fm; result += fd; return result; } void jul2french( long jd, int & fd, int & fm, int & fy ) { // From Edward M. Reingold and Nachum Dershowitz - "Calendrical // Calculations: The Millennium Edition" (Cambridge University // Press, 2001) - page 238 // // A first approximation of the year in the French Revolutionary // Calendar is found, and refined; then, the precise date is // computed from the Julian Day number corresponding to the start of // the current Revolutionary year. if (jd < frenchEpoch) { throw std::domain_error("Before the French Revolution"); } long approx = jd - frenchEpoch + 2; fy = static_cast(static_cast(approx)/daysPerFrenchYear) + 1; long startOfYear = french2jul(1, 1, fy); if (jd < startOfYear) { startOfYear = french2jul(1, 1, --fy); // We were wrong by 1 year... } fm = (jd -= startOfYear) / 30; fd = jd - 30 * fm++ + 1; }