View Code? Open in Web Editor
NEW
Converter between date in Milesian and Julian day.
License: MIT License
milesian_converter_php's People
Contributors
Watchers
milesian_converter_php's Issues
I tried to open the code in browser and got below error. Can we hae this in english?
- ? $juliandate ["relativeyear"] : $juliandate ["relativeyear"] - 1; // PHP uses non-zero years fir Julian and Gregorian calendars$juliandate ["month"] = (int) $_POST ["jmonth"];$juliandate ["day"] = (int) $_POST ["jquant"];$gregdate ["relativeyear"] = (int) $_POST ["gyear"];$gregdate ["year"] = ($gregdate ["relativeyear"] >0) ? $gregdate ["relativeyear"] : $gregdate ["relativeyear"] - 1; // PHP uses non-zero years fir Julian and Gregorian calendars$gregdate ["month"] = (int) $_POST ["gmonth"];$gregdate ["day"] = (int) $_POST ["gquant"];$jewdate ["year"] = (int) $_POST ["hyear"]; // No special handling of the negative Jewish years, the world did not exist at that time...$jewdate ["month"] = (int) $_POST ["hmonth"];$jewdate ["day"] = (int) $_POST ["hquant"]; // switch ($_POST ["Compute"]) {case "Today" :$today = getdate(); // la date courante -- attention le tableau reçu de getdate n'a pas la même structure que $md.$message = "Dates et jour julien aujourd'hui";$jd = gregoriantojd ($today["mon"], $today["mday"], $today["year"]); // Julian day of today$md = cal_from_jd_milesian ($jd); // Milesian date of today$juliandate = cal_from_jd ($jd, CAL_JULIAN);$juliandate ["relativeyear"] = ($juliandate ["year"] < 0) ? $juliandate ["year"] + 1 : $juliandate ["year"]; // PHP uses non-zero years fir Julian and Gregorian calendars$gregdate = cal_from_jd ($jd, CAL_GREGORIAN);$gregdate ["relativeyear"] = ($gregdate ["year"] < 0) ? $gregdate ["year"] + 1 : $gregdate ["year"]; // PHP uses non-zero years fir Julian and Gregorian calendars$jewdate = cal_from_jd ($jd, CAL_JEWISH);$wd = french_weekday_name($md["dow"]);break;case "Shift" : try {$jd1 = $jd + $days;$tempd1 = cal_from_jd_milesian ($jd1); // Exception may occur here. If catched, next instructions will not be performed.$jd = $jd1;$md = $tempd1;$juliandate = cal_from_jd ($jd, CAL_JULIAN);$juliandate ["relativeyear"] = ($juliandate ["year"] < 0) ? $juliandate ["year"] + 1 : $juliandate ["year"]; // PHP uses non-zero years for Julian and Gregorian calendars$gregdate = cal_from_jd ($jd, CAL_GREGORIAN);$gregdate ["relativeyear"] = ($gregdate ["year"] < 0) ? $gregdate ["year"] + 1 : $gregdate ["year"]; // PHP uses non-zero years for Julian and Gregorian calendars$jewdate = cal_from_jd ($jd, CAL_JEWISH);$wd = french_weekday_name($md["dow"]);}catch (Exception $e) {$message = "Jour julien irrégulier ou hors limites";}break;case "JulianDay" : try {$tempd1 = cal_from_jd_milesian ($jd); // Exception may occur here. If catched, next instructions will not be performed.$md = $tempd1;$juliandate = cal_from_jd ($jd, CAL_JULIAN);$juliandate ["relativeyear"] = ($juliandate ["year"] < 0) ? $juliandate ["year"] + 1 : $juliandate ["year"]; // PHP uses non-zero years fir Julian and Gregorian calendars$gregdate = cal_from_jd ($jd, CAL_GREGORIAN);$gregdate ["relativeyear"] = ($gregdate ["year"] < 0) ? $gregdate ["year"] + 1 : $gregdate ["year"]; // PHP uses non-zero years fir Julian and Gregorian calendars$jewdate = cal_from_jd ($jd, CAL_JEWISH); $wd = french_weekday_name($md["dow"]);}catch (Exception $e) {$message = "Jour julien irrégulier ou hors limites";}break;case "Milesian" : try {$jd1 = milesiantojd ($md ["month"],$md ["day"],$md ["year"]); // Exception may occur here. If catched, next instructions will not be performed.$jd = $jd1;$md = cal_from_jd_milesian ($jd); // In order to replenish the "monthname" field.$juliandate = cal_from_jd ($jd, CAL_JULIAN);$juliandate ["relativeyear"] = ($juliandate ["year"] < 0) ? $juliandate ["year"] + 1 : $juliandate ["year"]; // PHP uses non-zero years fir Julian and Gregorian calendars$gregdate = cal_from_jd ($jd, CAL_GREGORIAN);$gregdate ["relativeyear"] = ($gregdate ["year"] < 0) ? $gregdate ["year"] + 1 : $gregdate ["year"]; // PHP uses non-zero years fir Julian and Gregorian calendars$jewdate = cal_from_jd ($jd, CAL_JEWISH);$wd = french_weekday_name(jddayofweek($jd));}catch (Exception $e) {$message = "Date irrégulière ou hors limites";}break;case "Julian" : try {$jd1 = juliantojd ($juliandate ["month"],$juliandate ["day"],$juliandate ["year"]); // Exception may occur here. If catched, next instructions will not be performed.$jd = $jd1;$md = cal_from_jd_milesian ($jd);$juliandate = cal_from_jd ($jd, CAL_JULIAN);$juliandate ["relativeyear"] = ($juliandate ["year"] < 0) ? $juliandate ["year"] + 1 : $juliandate ["year"]; // PHP uses non-zero years fir Julian and Gregorian calendars$gregdate = cal_from_jd ($jd, CAL_GREGORIAN);$gregdate ["relativeyear"] = ($gregdate ["year"] < 0) ? $gregdate ["year"] + 1 : $gregdate ["year"]; // PHP uses non-zero years fir Julian and Gregorian calendars$jewdate = cal_from_jd ($jd, CAL_JEWISH);$wd = french_weekday_name(jddayofweek($jd));}catch (Exception $e) {$message = "Date irrégulière ou hors limites";}break;case "Gregorian" : try {$jd1 = gregoriantojd ($gregdate ["month"],$gregdate ["day"],$gregdate ["year"]); // Exception may occur here. If catched, next instructions will not be performed.// if ($jd1 <= 0) throw new DomainException("Invalid date (Gregorian)");$jd = $jd1;$md = cal_from_jd_milesian ($jd);$juliandate = cal_from_jd ($jd, CAL_JULIAN);$juliandate ["relativeyear"] = ($juliandate ["year"] < 0) ? $juliandate ["year"] + 1 : $juliandate ["year"]; // PHP uses non-zero years fir Julian and Gregorian calendars$gregdate = cal_from_jd ($jd, CAL_GREGORIAN);$gregdate ["relativeyear"] = ($gregdate ["year"] < 0) ? $gregdate ["year"] + 1 : $gregdate ["year"]; // PHP uses non-zero years fir Julian and Gregorian calendars$jewdate = cal_from_jd ($jd, CAL_JEWISH);$wd = french_weekday_name(jddayofweek($jd));}catch (Exception $e) {$message = "Date irrégulière ou hors limites";}break;case "Hebraic" : try {$jd1 = jewishtojd ($jewdate ["month"],$jewdate ["day"],$jewdate ["year"]); // Exception may occur here. If catched, next instructions will not be performed.$jd = $jd1;$md = cal_from_jd_milesian ($jd);$juliandate = cal_from_jd ($jd, CAL_JULIAN);$juliandate ["relativeyear"] = ($juliandate ["year"] < 0) ? $juliandate ["year"] + 1 : $juliandate ["year"]; // PHP uses non-zero years fir Julian and Gregorian calendars$gregdate = cal_from_jd ($jd, CAL_GREGORIAN);$gregdate ["relativeyear"] = ($gregdate ["year"] < 0) ? $gregdate ["year"] + 1 : $gregdate ["year"]; // PHP uses non-zero years fir Julian and Gregorian calendars$jewdate = cal_from_jd ($jd, CAL_JEWISH);$wd = french_weekday_name(jddayofweek($jd));}catch (Exception $e) {$message = "Date irrégulière ou hors limites";}break; } } else { // No data posted: prepare data of today, to be inserted in first form$today = getdate(); // la date courante -- attention le tableau reçu de getdate n'a pas la même structure que $md.$message = "Dates et jour julien aujourd'hui";$days = 1;$jd = gregoriantojd ($today["mon"], $today["mday"], $today["year"]); // Julian day of today$md = cal_from_jd_milesian ($jd); // Milesian date of today$wd = french_weekday_name($md["dow"]);$juliandate = cal_from_jd ($jd, CAL_JULIAN);$juliandate ["relativeyear"] = ($juliandate ["year"] < 0) ? $juliandate ["year"] + 1 : $juliandate ["year"]; // PHP uses non-zero years fir Julian and Gregorian calendars$gregdate = cal_from_jd ($jd, CAL_GREGORIAN);$gregdate ["relativeyear"] = ($gregdate ["year"] < 0) ? $gregdate ["year"] + 1 : $gregdate ["year"]; // PHP uses non-zero years fir Julian and Gregorian calendars$jewdate = cal_from_jd ($jd, CAL_JEWISH); } ?>