PHP Conference Japan 2024

jdtofrench

(PHP 4, PHP 5, PHP 7, PHP 8)

jdtofrench將儒略日計數轉換為法國共和曆

說明

jdtofrench(int $julian_day): string

將儒略日計數轉換為法國共和曆。

參數

julian_day

儒略日數,整數

回傳值

法國大革命日期,格式為字串 "月/日/年"

參見

新增筆記

使用者貢獻的筆記 4 則筆記

pieterc dot depraetere at ugent dot be
14 年前
如果您想轉換 1806 年 9 月 22 日之後的日期,您可以使用這個函式。這個函式有點粗糙,由於原始函式在 1806 年中終止,它使用 1805 年作為它的「終止後限」。
<?php
function extended_jdtofrench ($juliandate) {
if (
$juliandate > 2380945) {
// jdtofrench () 只接受到 1806 年 9 月的日期
$gregorian_date = jdtogregorian ($juliandate);
$temp = explode ('/', $gregorian_date);
$year = $temp[2];
$juliandate = gregoriantojd ($temp[0], $temp[1], 1805);
$republican_date = jdtofrench ($juliandate);
$republican_date = explode ('/', $republican_date);
$diff = $year - 1805;
$republican_date[2] = $republican_date[2] + $diff;
} else {
$republican_date = jdtofrench ($juliandate);
}
return
$republican_date;
}
?>
squenz at titania dot bottoms-dream dot de
18 年前
以下是一小段程式碼,用於獲取正確轉換的格里高利日期的字串數據。

<?php
$arDateFrench
= gregorian2FrenchDateArray(11, 9, 1799) ;

echo
$arDateFrench[1] . " " . $arDateFrench[0] . " " . $arDateFrench[2] ;

/* the output will be:
18 Brumaire VIII

*/

function gregorian2FrenchDateArray($m, $d, $y)
{

$julian_date = gregoriantojd($m, $d, $y);
$french = jdtofrench($julian_date);
if(
$french == "0/0/0")
return
"" ;

$arD = split("/", $french) ;

// get the month name
$monthname = FrenchMonthNames($arD[0]) ;

/* convert the year number to roman digits (as most historians do and documents of the time did */
$stryear = decrom($arD[2]) ;
return array(
$monthname, $arD[1], $stryear ) ;
}

function
FrenchMonthNames($mo)
{
/* The names have been invented by Fabre d'Églantine, a second or rather third rank poet
of primarily pastoral poems, with each name referring to the respective period in the agricultural year; e.g. "Vendémiaire" (approx. September) is derived from "vendange" ("harvest"), "Brumaire" (Ocotober/November) from "brume" ("fog") and so on ... */


$arMo = array("Vendémiaire",
"Brumaire",
"Frimaire",
"Nivôse",
"Pluviôse",
"Ventôse",
"Germinal",
"Floréal",
"Prairial",
"Messidor",
"Thermidor",
"Fructidor",
"Sansculottide") ;

if(
$mo < count($arMo)+1)
return
$arMo[$mo-1] ;

}

function
decrom($dec){
$digits=array(
1 => "I",
4 => "IV",
5 => "V",
9 => "IX",
10 => "X",
40 => "XL",
50 => "L",
90 => "XC",
100 => "C",
400 => "CD",
500 => "D",
900 => "CM",
1000 => "M"
);
krsort($digits);
$retval="";
foreach(
$digits as $key => $value){
while(
$dec>=$key){
$dec-=$key;
$retval.=$value;
}
}
return
$retval;
}
?>
popy-dev
6 年前
另請注意,除了 jdtofrench 涵蓋的範圍外,很少有日期轉換器可以處理法國共和曆。
serged at noos dot fr
21 年前
功能非常有限

(摘自 4.3.3 版本原始碼)
這些例程僅轉換公元 1 年到 14 年的日期(格里高利曆 1792 年 9 月 22 日到 1806 年 9 月 22 日)。這涵蓋了該曆法使用期間的完整時間,甚至更長。

給法國人的說明 (法文原文)
Ces routines ne converitssent les dates que de l'an 1 à 14 (du 22 septembre 1792 au 22 septembre 1806). Cela couvre plus que la période pendant laquelle le calendrier a été utilisé.
To Top