123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- #include "sdncal.h"
- #define FRENCH_SDN_OFFSET 2375474
- #define DAYS_PER_4_YEARS 1461
- #define DAYS_PER_MONTH 30
- #define FIRST_VALID 2375840
- #define LAST_VALID 2380952
- void SdnToFrench(
- zend_long sdn,
- int *pYear,
- int *pMonth,
- int *pDay)
- {
- zend_long temp;
- int dayOfYear;
- if (sdn < FIRST_VALID || sdn > LAST_VALID) {
- *pYear = 0;
- *pMonth = 0;
- *pDay = 0;
- return;
- }
- temp = (sdn - FRENCH_SDN_OFFSET) * 4 - 1;
- *pYear = temp / DAYS_PER_4_YEARS;
- dayOfYear = (temp % DAYS_PER_4_YEARS) / 4;
- *pMonth = dayOfYear / DAYS_PER_MONTH + 1;
- *pDay = dayOfYear % DAYS_PER_MONTH + 1;
- }
- zend_long FrenchToSdn(
- int year,
- int month,
- int day)
- {
-
- if (year < 1 || year > 14 ||
- month < 1 || month > 13 ||
- day < 1 || day > 30) {
- return (0);
- }
- return ((year * DAYS_PER_4_YEARS) / 4
- + (month - 1) * DAYS_PER_MONTH
- + day
- + FRENCH_SDN_OFFSET);
- }
- const char * const FrenchMonthName[14] =
- {
- "",
- "Vendemiaire",
- "Brumaire",
- "Frimaire",
- "Nivose",
- "Pluviose",
- "Ventose",
- "Germinal",
- "Floreal",
- "Prairial",
- "Messidor",
- "Thermidor",
- "Fructidor",
- "Extra"
- };
|