fisharebest / webtrees

Online genealogy
https://webtrees.net
GNU General Public License v3.0
417 stars 290 forks source link

Add Chinese Lunar Support #2239

Open DaPoHou opened 5 years ago

DaPoHou commented 5 years ago

I found that the program contains the Hebrew/Jewish/Hijri calendar. But there is no Chinese lunar calendar. The birthdays of Chinese people around the world are based on the date of the lunar calendar. I hope to add support for the Chinese Lunar Date. Or integrate the code below.

https://github.com/guojikai/plunar (A PHP version of the Chinese lunar conversion tool for converting the Gregorian date to the Chinese lunar date.)

In addition: Translation website is unable to open, 502 error https://translate.webtrees.net/

DaPoHou commented 4 years ago

https://github.com/liujiawm/paipan This Chinese Lunar and Gregorian calendar conversion is no longer limited by the 1891 year.

This is the calculation principle: http://www.bieyu.com/

thiDucTran commented 2 years ago

There is also Vietnamese Lunar Calendar which can may be utilize external sites for the conversion?

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://www.xemlicham.com/app/doi-ngay-duong-sang-am");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,'cdate=05%2F01%2F2022');  //Post Fields
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$headers = [
            'Host: www.xemlicham.com',
            'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
            'Content-Type: application/x-www-form-urlencoded',
            'Origion: https://www.xemlicham.com',
            'DNT: 1',
            'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:95.0) Gecko/20100101 Firefox/95.0'
];

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$server_output = curl_exec ($ch);
curl_close ($ch);
libxml_use_internal_errors(true);
$dom = DOMDocument::loadHTML($server_output);
libxml_clear_errors();
$finder = new DOMXPath($dom);
$classname='lunar-date';
$spans = $finder->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' $classname ')]");
$lunar_date = trim($spans->item(0)->firstChild->nodeValue);
print ("05-Jan-2022 Gregorian is $lunar_date in Vietnamese Lunar Calendar\r\n");
?>
DaPoHou commented 9 months ago

http://sinocal.sinica.edu.tw/ After a lot of experiments, this website is the website of Taiwan’s Academia Sinica, which is the most accurate in converting between the Gregorian calendar and the lunar calendar. And provides calculation methods.