Code Monkey home page Code Monkey logo

chinese-calendar's Issues

八字计算:日柱和时柱结果错误

您好,我在使用这个 Lib 的时候遇到了一个八字计算结果错误的问题

输入:1991-08-21 12:00:00

错误示例
image

正确示例
image

感谢作者的贡献。

关于时辰,早子时晚子时的讨论

之前发 PR #12 的时候没考虑到早子时和晚子时对日柱的影响(怪百度百科里没说,哼都是百度的错)

今天在用别人的软件时发现
2018-03-31 23点 和 2018-03-31 00点 的农历是不一样的
23点的农历是 二月廿五子时
00点的农历是 二月廿四子时

google 了下,大部分的结论都是古时与子时为一天的开始,23点后就算新一天的开始,所以日柱应该加一天

所以当 $hour 参数为 23 时,是否有必要将日柱加一天?如果需要的话,我再提个 PR,顺便把 $hour 参数的说明在 README 更新下

参考:
早子與晚子都是子時
飄風點萃....有關.早子.與.晚子..乃至於..日柱的界定與關照..之ㄧ..
子时,分早子时、晚子时?命理学上最画蛇添足的说法。

composer require 出错

Could not find package overtrue/chinese-calendar at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability

菜鸡建议,if (可笑) 请忽略。

我用 sql:DATE_FORMAT(birthday, '%m-%d') 来查今天过生日的会员。
本轮子转换出的农历月日 是没有补0的,刚才提取出来的月何日 6-7 这样,直接插发现不行要06-07这样。

下个版本 神超是否考虑这个农历的月和日也以06-07这样呢,因为有中文的六月初七,感觉这里补0

如果感觉此建议实在可笑请忽略。

实例化在centos上页面找不到了


以上这段代码,在windows平台的xampp的apache正常运行没有问题, 可是放到centos上,输入地址,页面直接就找不到了,请问,你们有人遇到过吗?

Parse error ???

Parse error: syntax error, unexpected '[' in /chinese-calendar-master/src/Calendar.php on line 28

readme 拼错了

$result = $calendar->lunlar(2017, 4, 10); // 阴历
应该是
$result = $calendar->lunar(2017, 4, 10); // 阴历

32bit系统下的bug

// 1900 年农历正月一日的公历时间为 1900 年 1 月 30 日 0 时 0 分 0 秒 (该时间也是本农历的最开始起始点)
        $startTimestamp = mktime(0, 0, 0, 1, 30, 1900);
        $date = date('Y-m-d', ($offset + $day) * 86400 + $startTimestamp);

mktime在32位系统下超出了2^31返回false,取值范围1901-12-14到2038-01-19

干支的年份计算错了 2022-01-20 是辛丑年 算成了壬寅年

     * 农历年份转换为干支纪年.
     *
     * @param int      $lunarYear
     * @param null|int $termIndex
     *
     * @return string
     */
    public function ganZhiYear($lunarYear, $termIndex = null)
    {
        /**
         * 据维基百科干支词条:『在西历新年后,华夏新年或干支历新年之前,则续用上一年之干支』
         * 所以干支年份应该不需要根据节气校正,为免影响现有系统,此处暂时保留原有逻辑
         * https://zh.wikipedia.org/wiki/%E5%B9%B2%E6%94%AF.
         *
         * 即使考虑节气,有的年份没有立春,有的年份有两个立春,此处逻辑仍不能处理该特殊情况
         */
        $adjust = (null !== $termIndex && 3 > $termIndex) ? 1 : 0;

        $ganKey = ($lunarYear + $adjust - 4) % 10;
        $zhiKey = ($lunarYear + $adjust - 4) % 12;

        return $this->gan[$ganKey].$this->zhi[$zhiKey];
    }```
    
    
    这里 3 > $termIndex 应该是 3 <= $termIndex
    我没有仔细研究农历,你看看这里是不是写错了。

I found some php version get your dateDiff not correctly

I found some php version get your dateDiff not same value. I change from makeDate to date_create will work well.

public function dateDiff($date1, $date2)
{

    $date1 = date_create($date1);
    $date2 = date_create($date2);
    $diff = date_diff($date1,$date2);

    return $diff;

    /* Original
    if (!($date1 instanceof DateTime)) {
        $date1 = $this->makeDate($date1);
    }

    if (!($date2 instanceof DateTime)) {
        $date2 = $this->makeDate($date2);
    }

    return $date1->diff($date2);
    */
}

生肖计算不对

阳历日期:1939-01-06
阴历日期:1938冬月十六
生肖:虎

计算结果生肖为:兔

以上仅仅是我提供的一个日期,还有后续好多日期都有问题

问题2:

string(10) "2001-02-02"
string(16) "2001正月初十"
string(16) "2001正月初十"
string(3) "蛇"
string(3) "蛇"
string(10) "2001-02-03"
string(16) "2001正月十一"
string(16) "2001正月十一"
string(3) "蛇"
string(3) "蛇"
string(10) "2001-02-04"
string(16) "2001正月十二"
string(16) "2001正月十二"
string(3) "蛇"
string(3) "马" //此处生肖突然变化。。。
string(10) "2001-02-05"
string(16) "2001正月十三"
string(16) "2001正月十三"
string(3) "蛇"
string(3) "蛇"

阳历转阴历的bug

23时,对day+1
如果是5月31日,那么这里就变成 5月32日了,直接出错

498行

        if (23 == $hour) {
            // 23点过后算子时,农历以子时为一天的起始
            $day += 1;
        }
        $date = $this->makeDate("{$year}-{$month}-{$day}");

改为

        if (23 == $hour) {
            // 23点过后算子时,农历以子时为一天的起始
            $date = $this->makeDate("{$year}-{$month}-{$day} +1day");
        } else {
            $date = $this->makeDate("{$year}-{$month}-{$day}");
        }

lunar2solar 问题。。。

lunar2solar 方法

$calendar = new Calendar();
$result = $calendar->lunar2solar(2017, 04, 02);

返回:

array(3) {
  ["solar_year"] =&gt; string(4) "1951"
  ["solar_month"] =&gt; string(2) "03"
  ["solar_day"] =&gt; string(2) "01"
}

为什么是 1951年3月1日,农历 2017 四月初二 应该是今天 2017年4月27啊

Bug with some date

This date 20.01.1981 (d-m-Y) year of the Monkey, but recognize as Rooster. Can you check please?

**实行夏令时期间农历计算错误

// 这里输出 26
echo (new Overtrue\ChineseCalendar\Calendar())->solar2lunar(1986, 5, 4)['lunar_day'];

// 这里还是输出 26
echo (new Overtrue\ChineseCalendar\Calendar())->solar2lunar(1986, 5, 5)['lunar_day'];

大佬能不能处理一下,很急,不弄好老板要开除我

阳历转阴历报错--bug

阳历时间:2019-4-30

   InvalidArgumentException  : 传入的参数不合法

  at /home/hr/jz-yibashou/vendor/overtrue/chinese-calendar/src/Calendar.php:750
    746|         }
    747|
    748|         // 参数合法性效验
    749|         if ($year < 1900 || $year > 2100 || $day > $maxDays) {
  > 750|             throw new InvalidArgumentException('传入的参数不合法');
    751|         }
    752|
    753|         // 计算农历的时间差
    754|         $offset = 0;

  Exception trace:

  1   Overtrue\ChineseCalendar\Calendar::lunar2solar()
      /home/hr/jz-yibashou/vendor/overtrue/chinese-calendar/src/Calendar.php:250

  2   Overtrue\ChineseCalendar\Calendar::lunar()
      /home/hr/jz-yibashou/app/Transformers/EmployeesBaseTransformer.php:77

  Please use the argument -v to see more details.

阳历转阴历日期bug

阳历日期:1996-07-15
正确阴历日期:1996五月三十(百度万年历)
阳历转阴历日期:1996六月初一

以上仅我提供的一个日期,还有后续好多日期不对

来点建议

1、时辰
2、地支
3、是否闰年
4、是否闰月
5、农历月总天数
6、农历年总天数
7、期距离本年的正月初一有多少天
8、农历每月最后一天是哪天
9、每月最后一天是该农历总天数的第几天
10、计算农历第一天到指定时间相隔多少天

等等。。。
哈哈

實驗用在MediaWiki的Extension上

https://www.mediawiki.org/wiki/Extension:LunarFunctions

除了動到 namespace

//namespace Overtrue\ChineseCalendar;
namespace MediaWiki\Extensions\LunarFunctions;

本來是想把字串的簡体字都改成繁體字的
但是想以後配合MediaWiki的i18n的做法
所以只動了一行,其他的就先沒改了

//$constellations = '魔羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯';
$constellations = '魔羯水瓶双魚白羊金牛双子巨蟹獅子處女天秤天蝎射手魔羯';

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.