diff --git a/README.md b/README.md index 3b7610a..561b179 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# Republicain-Calendar-PHP +# PHP Romme Republican Calendar -Juste un petit convertisseur de date en calendrier républicain pour ceux qui le souhaite. Le script peut afficher soit une date minimale (style 23 Brumaire, an 225) soit une date plus complexe (Tridi, 23 Brumaire, an 225 - Garance). +Une librairie PHP pour couvertir facilement une date dans le calendrier républicain, utilisant le [système Romme](http://prairial.free.fr/calendrier/calendrier.php?lien=discoursromme). -Il utilise le système Romme pour calculer la date. +Le script peut afficher soit une date minimale (style 23 Brumaire, an 225) soit une date plus complexe (Tridi, 23 Brumaire, an 225 - Garance). ## Comment l'utiliser. diff --git a/exemple.php b/exemple.php index c2ac5b4..7466117 100644 --- a/exemple.php +++ b/exemple.php @@ -1,6 +1,6 @@ - republicandate :: exemple.php + PHP Romme Republican Calendar exemple -

republicandate :: exemple.php

+

PHP Romme Republican Calendar exemples

Date d'aujourd'hui

Date utilisée : //
@@ -36,8 +36,8 @@ $testJulianday = gregoriantojd($testMois, $testJour, $testAnnee);

jdtoromme :
gregoriantoromme :
- gregorian2FrenchDateString :
- gregorian2FrenchDateStringShort :
+ gregorian2FrenchDateString :
+ gregorian2FrenchDateStringShort :

diff --git a/romme-calendar.php b/romme-calendar.php new file mode 100644 index 0000000..d6b4167 --- /dev/null +++ b/romme-calendar.php @@ -0,0 +1,258 @@ + gregoriantojd (9, 22, 1805)) or ($debugCalendar==1)) { // Ce calcul prend le relais à partir du 23 septembre 1805 + // On commence par déclarer les variables, qui nous servirons à calculer ou on en est rendu. + $franciade_simple_nbr_jours = (3*365)+366; + $siecle_simple_nbr_jour = (25*$franciade_simple_nbr_jours)-1; + $siecle_quatrieme_nbr_jour = 25*$franciade_simple_nbr_jours; + $franciade_seculaire_nbr_jours = 3*$siecle_simple_nbr_jour+$siecle_quatrieme_nbr_jour; + $franciade_millenaire_nbr_jours = (10*$franciade_seculaire_nbr_jours)-1; + // On obtien le jour courrant par rapport au début du calendrier révolutionaire + $rommedate = $juliandaycount - gregoriantojd (9, 22, 1792); + + if ($debugCalendar==1) { + echo $rommedate . " jours se sont écoulés depuis le debut du calendrier revolutionnaire.
"; + } + + // On découpe ce jour courrant suivant les années. + $franciade_millenaire = floor($rommedate/$franciade_millenaire_nbr_jours); + $rommedate = $rommedate % $franciade_millenaire_nbr_jours; + + if ($debugCalendar==1) { + echo $franciade_millenaire . " franciades millénaires ( de " . $franciade_millenaire_nbr_jours . " jours ) se sont écoulées depuis le début du calendrier révolutionnaire. " . $rommedate . " jours se sont écoulés depuis le début de la franciade millénaire actuelle
"; + } + + $franciade_seculaire = floor($rommedate/$franciade_seculaire_nbr_jours); + $rommedate = $rommedate % $franciade_seculaire_nbr_jours; + + if ($debugCalendar==1) { + echo $franciade_seculaire . " franciades séculaires ( de " . $franciade_seculaire_nbr_jours . " jours ) se sont écoulées depuis le début de la franciade millénaire. " . $rommedate . " jours se sont écoulé depuis le début de la franciade séculaire actuelle
"; + } + + if ($rommedate < (3*$siecle_simple_nbr_jour)) { + $siecle = floor($rommedate/$siecle_simple_nbr_jour); + $rommedate = $rommedate % $siecle_simple_nbr_jour; + } else { + $siecle = 3; + $rommedate = $rommedate - (3*$siecle_simple_nbr_jour); + } + + if ($debugCalendar==1) { + echo $siecle . " siècles ( de " . $siecle_simple_nbr_jour . " jours ) se sont écoulées depuis le début de la franciade séculaire. " . $rommedate . " jours se sont écoulé depuis le début du siècle actuel
"; + } + + $franciade_simple = floor($rommedate/$franciade_simple_nbr_jours); + $rommedate = $rommedate % $franciade_simple_nbr_jours; + + if ($debugCalendar==1) { + echo $franciade_simple . " franciades simples ( de " . $franciade_simple_nbr_jours . " jours ) se sont écoulées depuis le début du siècle. " . $rommedate . " jours se sont écoulé depuis le début de la franciade actuelle
"; + } + + if ($rommedate < (3*365)) { + $annees = floor($rommedate/365); + $rommedate = $rommedate % 365; + } else { + $annees = 3; + $rommedate = $rommedate - (3*365); + } + + if ($debugCalendar==1) { + echo $annees . " années non-sextiles ( de 365 jours ) se sont écoulées depuis le début de la franciade. " . $rommedate . " jours se sont écoulé depuis le début de l'année
"; + } + + $annees = ($franciade_millenaire*4000)+($franciade_seculaire*400)+($siecle*100)+($franciade_simple*4)+$annees; + $mois = floor($rommedate/30); + $jours = ($rommedate % 30); + + if ($debugCalendar==1) { + echo $mois . " mois ( de 30 jours ) se sont écoulées depuis le début de l'année. " . $jours . " jours se sont écoulé depuis le début du mois
"; + } + + // On rajoute à chaque élément un numéro en plus, parce qu'une date ne commence jamais par 0 :) + $annees = $annees+1; + $mois = $mois+1; + $jours = $jours+1; + + $romme_date_string = $mois . "/" . $jours . "/" . $annees; + } else { + // Sinon on utilise le calcul de la fonction normal, qui nous permet d'avoir les valeurs révolutionnaires exactes + $romme_date_string = jdtofrench ( $juliandaycount ); + } + + return $romme_date_string; +} + +function gregoriantoromme($m, $d, $y) { + $juliandaycount = gregoriantojd($m, $d, $y); + $romme_date_string = jdtoromme($juliandaycount); + + return $romme_date_string; +} + +function jdtoromme_getArray($juliandaycount) { + $romme_date_string = jdtoromme($juliandaycount); + + $rommeArray = romme_getArray($romme_date_string); + + return $rommeArray; +} + +function gregoriantoromme_getArray($m, $d, $y) { + $romme_date_string = gregoriantoromme($m, $d, $y); + + $rommeArray = romme_getArray($romme_date_string); + + return $rommeArray; +} + +function romme_getArray($romme_date_string) { + $rommeArray = explode("/", $romme_date_string); + + return $rommeArray; +} + +function romme_getMonthName($month) +{ + // Convert a month number to the right republican calendar month name. + + // Month names comes from Fabre d'Eglantine : https://en.wikipedia.org/wiki/French_Republican_calendar#Months + $monthArray = array("Vendémiaire", + "Brumaire", + "Frimaire", + "Nivôse", + "Pluviôse", + "Ventôse", + "Germinal", + "Floréal", + "Prairial", + "Messidor", + "Thermidor", + "Fructidor", + "Sansculottide"); // The "13th" month is a special case for the sanscullotide, + // the leap days of the republican calendar. + if($month < count($monthArray)+1) { + return $monthArray[$month-1]; + } +} + +function romme_getDayName($day) +{ + // Convert a month day number to the right republican calendar day name. + // /!\ Do not use if you are in the sansculottides days, as *technically*, they aren't part of any decade. + + // Days names comes from Fabre d'Eglantine : https://en.wikipedia.org/wiki/French_Republican_calendar#Ten_days_of_the_week + $dayArray = array( "Primidi", + "Duodi", + "Tridi", + "Quartidi", + "Quintidi", + "Sextidi", + "Septidi", + "Octidi", + "Nonidi", + "Décadi") ; + + + // As the republican calendar use a ten-day decade and a thirty-day month, just derive the decade day from day month modulo ten. + + return $dayArray[($day-1) % 10] ; +} + +function romme_getEpiphany($month, $day) { + // Convert a romme day and month number to the corresponding epiphany name. + + // Days names comes from Fabre d'Eglantine : https://en.wikipedia.org/wiki/French_Republican_calendar#Rural_Calendar + $epiphanyArray = array('Raisin','Safran','Châtaigne','Colchique','Cheval','Balsamine','Carotte','Amaranthe','Panais','Cuve','Pomme de terre','Immortelle','Potiron','Réséda','Âne','Belle de nuit','Citrouille','Sarrasin','Tournesol','Pressoir','Chanvre','Pêche','Navet','Amaryllis','Bœuf','Aubergine','Piment','Tomate','Orge','Tonneau', 'Pomme','Céleri','Poire','Betterave','Oie','Héliotrope','Figue','Scorsonère','Alisier','Charrue','Salsifis','Mâcre','Topinambour','Endive','Dindon','Chervis','Cresson','Dentelaire','Grenade','Herse','Bacchante','Azerole','Garance','Orange','Faisan','Pistache','Macjonc','Coing','Cormier','Rouleau', 'Raiponce','Turneps','Chicorée','Nèfle','Cochon','Mâche','Chou-fleur','Miel','Genièvre','Pioche','Cire','Raifort','Cèdre','Sapin','Chevreuil','Ajonc','Cyprès','Lierre','Sabine','Hoyau','Érable sucré','Bruyère','Roseau','Oseille','Grillon','Pignon','Liège','Truffe','Olive','Pelle', 'Tourbe','Houille','Bitume','Soufre','Chien','Lave','Terre végétale','Fumier','Salpêtre','Fléau','Granit','Argile','Ardoise','Grès','Lapin','Silex','Marne','Pierre à chaux','Marbre','Van','Pierre à plâtre','Sel','Fer','Cuivre','Chat','Étain','Plomb','Zinc','Mercure','Crible', 'Lauréole','Mousse','Fragon','Perce-neige','Taureau','Laurier tin','Amadouvier','Mézéréon','Peuplier','Coignée','Ellébore','Brocoli','Laurier','Avelinier','Vache','Buis','Lichen','If','Pulmonaire','Serpette','Thlaspi','Thimele','Chiendent','Trainasse','Lièvre','Guède','Noisetier','Cyclamen','Chélidoine','Traîneau', 'Tussilage','Cornouiller','Violier','Troène','Bouc','Asaret','Alaterne','Violette','Marceau','Bêche','Narcisse','Orme','Fumeterre','Vélar','Chèvre','Épinard','Doronic','Mouron','Cerfeuil','Cordeau','Mandragore','Persil','Cochléaria','Pâquerette','Thon','Pissenlit','Sylvie','Capillaire','Frêne','Plantoir', 'Primevère','Platane','Asperge','Tulipe','Poule','Bette','Bouleau','Jonquille','Aulne','Couvoir','Pervenche','Charme','Morille','Hêtre','Abeille','Laitue','Mélèze','Ciguë','Radis','Ruche','Gainier','Romaine','Marronnier','Roquette','Pigeon','Lilas (commun)','Anémone','Pensée','Myrtile','Greffoir', 'Rose','Chêne','Fougère','Aubépine','Rossignol','Ancolie','Muguet','Champignon','Hyacinthe','Râteau','Rhubarbe','Sainfoin','Bâton-d´or','Chamerops','Ver à soie','Consoude','Pimprenelle','Corbeille d´or','Arroche','Sarcloir','Statice','Fritillaire','Bourrache','Valériane','Carpe','Fusain','Civette','Buglosse','Sénevé','Houlette', 'Luzerne','Hémérocalle','Trèfle','Angélique','Canard','Mélisse','Fromental','Martagon','Serpolet','Faux','Fraise','Bétoine','Pois','Acacia','Caille','Œillet','Sureau','Pavot','Tilleul','Fourche','Barbeau','Camomille','Chèvrefeuille','Caille-lait','Tanche','Jasmin','Verveine','Thym','Pivoine','Chariot', 'Seigle','Avoine','Oignon','Véronique','Mulet','Romarin','Concombre','Échalote','Absinthe','Faucille','Coriandre','Artichaut','Girofle','Lavande','Chamois','Tabac','Groseille','Gesse','Cerise','Parc','Menthe','Cumin','Haricot','Orcanète','Pintade','Sauge','Ail','Vesce','Blé','Chalemie', 'Épeautre','Bouillon-blanc','Melon','Ivraie','Bélier','Prêle','Armoise','Carthame','Mûre','Arrosoir','Panic','Salicorne','Abricot','Basilic','Brebis','Guimauve','Lin','Amande','Gentiane','Écluse','Carline','Câprier','Lentille','Aunée','Loutre','Myrte','Colza','Lupin','Coton','Moulin', 'Prune','Millet','Lycoperdon','Escourgeon','Saumon','Tubéreuse','Sucrion','Apocyn','Réglisse','Échelle','Pastèque','Fenouil','Épine vinette','Noix','Truite','Citron','Cardère','Nerprun','Tagette','Hotte','Églantier','Noisette','Houblon','Sorgho','Écrevisse','Bigarade','Verge d´or','Maïs','Marron','Panier'); + + if ($month < 13) { + $absoluteDay = (($month-1)*30)+$day; + if($absoluteDay < count($epiphanyArray)+1) { + return $epiphanyArray[$absoluteDay-1]; + } + } else { + return romme_getComplementaryDayName($day); + } +} +function romme_getComplementaryDayName($Day) { + // Convert the sansculottide day number to its name. + + // Complentary Day names: https://en.wikipedia.org/wiki/French_Republican_calendar#Complementary_days + $sanscullotidesArray = array("Jour de la vertu", + "Jour du génie", + "Jour du travail", + "Jour de l'opinion", + "Jour des récompenses", + "Jour de la révolution"); + + if($Day < count($sanscullotidesArray)+1) + return $sanscullotidesArray[$Day-1] ; +} + +function romme_getComplementaryDay($Day) { + // Convert the sansculottide day number to a string. + + $ordinalnumberArray = array("Premier", + "Deuxième", + "Troisième", + "Quatrième", + "Cinquième", + "Sixième"); + + if($Day < count($ordinalnumberArray) + 1) { + $ordinalName = $ordinalnumberArray[$Day-1]; + $ordinalString = $ordinalName . " jour des Sanscullotides"; + + return $ordinalString; + } +} + +function gregoriantoromme_completeString($m,$d,$y) { + // Convert a gregorian date to a complete romme date string + + // Start by getting the romme array from the gregorian date + $dateArray = gregoriantoromme_getArray($m,$d,$y); + + // Get the month and day names + $monthname = romme_getMonthName($dateArray[0]) ; + $dayname = romme_getDayName($dateArray[1]); + + // If you are in a complentary day, show it the right way + if ($dateArray[0]==13) { + $dayMonthString = romme_getComplementaryDay($dateArray[1]) . ", "; + } else { + $dayMonthString = $dayname . ", " . $dateArray[1] . " " . $monthname . ", "; + } + + $saintString = romme_getComplementaryDayName($dateArray[0],$dateArray[1]); + + // Create the string for the year + $yearString = "an " . $dateArray[2]; + + return $dayMonthString . $yearString . "
" . $saintString . ""; +} + +function gregoriantoromme_simplerString($m,$d,$y) { + // Convert a gregorian date to a shorter romme date string + $dateArray = gregoriantoromme_getArray($m,$d,$y); + + // Get the month and day names + $monthname = romme_getMonthName($dateArray[0]); + $dayname = romme_getDayName($dateArray[1]); + + // If you are in a complentary day, show it the right way + if ($dateArray[0]==13) { + $dayMonthString = romme_getComplementaryDay($dateArray[1]) . ", "; + } else { + $dayMonthString = $dateArray[1] . " " . $monthname . ", "; + } + + // Create the string for the year + $yearString = "an " . $dateArray[2]; + + return $dayMonthString . $yearString; +} +?>