Code Monkey home page Code Monkey logo

Comments (37)

overtrue avatar overtrue commented on July 17, 2024

😆 无 fuck 说,肯定是 bug 了,但是这会儿我是真忙不过来搞它。请给我一些时间。

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

@overtrue 好,不急,那我就等了,找了N个农历阳历转换的类库,终于发现安神有这个轮子,还是安神的代码长的好看。

我还在 laravelChina 发了个贴,您忙完可以一并解答我这个菜鸡。
https://laravel-china.org/topics/4557/some-of-the-problems-of-soothing-chinese-calendar-ask-for-advice

from chinese-calendar.

momosc avatar momosc commented on July 17, 2024

$result = $calendar->lunar(2017, 4, 10); // 阴历 这个确实有问题

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

@momosc 有问题是的确的,但是安神 没有时间管这个轮子哈。

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

@overtrue 距离上次commit 已经一个月了,安神咱百忙之中家装抽空更新一下这个包呗,哪怕是修复一下bug。代码写的渣,实在不忍pr啊。

from chinese-calendar.

overtrue avatar overtrue commented on July 17, 2024

@tlerbao 为啥我的是
image

image

from chinese-calendar.

overtrue avatar overtrue commented on July 17, 2024

@momosc $calendar->lunar(2017, 4, 10) 的结果为:

{
    "lunar_year": 2017,
    "lunar_month": 4,
    "lunar_day": 10,
    "lunar_month_chinese": "四月",
    "lunar_day_chinese": "初十",
    "ganzhi_year": "丁酉",
    "ganzhi_month": "乙巳",
    "ganzhi_day": "壬辰",
    "animal": "",
    "term": "立夏",
    "is_leap": false,
    "gregorian_year": "2017",
    "gregorian_month": "05",
    "gregorian_day": "05",
    "week_no": 5,
    "week_name": "星期五",
    "is_today": false,
    "constellation": "金牛"
}

我也去翻了其它万年历,都是一样的啊,你说的有问题是指?

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

@overtrue 直接用 lunar2solar 方法 返回信息不对啊。

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

返回

array(3) {
  ["solar_year"] => string(4) "1951"
  ["solar_month"] => string(2) "02"
  ["solar_day"] => string(2) "21"
}

from chinese-calendar.

overtrue avatar overtrue commented on July 17, 2024

对啊,我就是这样用的啊

from chinese-calendar.

overtrue avatar overtrue commented on July 17, 2024

你的 PHP 版本是?

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

@overtrue
Win10
php 5.6.27-nts + nginx

from chinese-calendar.

overtrue avatar overtrue commented on July 17, 2024

靠,我的 PHP 7 是正常的,我换 5.6 试试

from chinese-calendar.

overtrue avatar overtrue commented on July 17, 2024

@tlerbao 我的 5.6 也正常 😆

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

@overtrue 难道我活见鬼了?

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

@overtrue 主要上面也有个朋友说有问题哈

from chinese-calendar.

overtrue avatar overtrue commented on July 17, 2024

建议你先更新看看,我觉得可能你装了旧版哈哈

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

@overtrue 我刚新 composer require overtrue/chinese-calendar -vvv 安装的

然后我切换到 php 7.0.12 还是上面一样的写法报错了

Calendar.php line 646
date() expects parameter 2 to be integer, float given

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

@overtrue 安神,有头绪么?是我的问题,还是怎样?

from chinese-calendar.

overtrue avatar overtrue commented on July 17, 2024

我找其它人试一下

from chinese-calendar.

jcc avatar jcc commented on July 17, 2024

175f0401-05cb-4db9-93a5-607422352e2d

25320940-7cd9-4fe7-b1fb-da979a6e702f

@tlerbao 测试了一下是没问题的

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

@jcc 我去 那我活见鬼了?请问您是 win 还是mac php版本?

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

@overtrue 很怪 阳历就非常正常 阴历就都1951-x-x

$calendar->solar(2017, 5, 11); // 阳历就非常正常
$calendar->lunar(2017, 5, 11) // 阴历就1951年x月x日,醉醉的啊。

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

@overtrue 我调试了一下发现 645 行
$startTimestamp = mktime(0, 0, 0, 1, 30, 1900);

这个$startTimestamp 是个bool(false) ,这似乎不正常。

from chinese-calendar.

overtrue avatar overtrue commented on July 17, 2024

@tlerbao 把你的错误打开 error_reporting(-1)

from chinese-calendar.

overtrue avatar overtrue commented on July 17, 2024

@tlerbao 更新版本

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

@overtrue 改成这样还是 $startTimestamp 还是返回false。

$startTimestamp = strtotime('1900-01-30 00:00:00');
dump($startTimestamp);

然后
($offset + $day) * 86400 + $startTimestamp
返回的时间戳 拿 $calendar->lunar(2017, 05, 11) 来说 生成的是 3703104000,2087/5/7 8:0:0

我尽量详细了,在php5.6下不报错。

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

@overtrue php 5.6 开启 error_reporting(-1)

Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in F:\WorkSpace\DolphinPHP\vendor\overtrue\chinese-calendar\src\Calendar.php on line 646

Warning: date(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in F:\WorkSpace\DolphinPHP\vendor\overtrue\chinese-calendar\src\Calendar.php on line 647

from chinese-calendar.

overtrue avatar overtrue commented on July 17, 2024

所以需要设置时区嘛

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

@overtrue 设置时区不报错了,但依然是1951年。。。菜的抠脚啊我

from chinese-calendar.

overtrue avatar overtrue commented on July 17, 2024

你是如何测试的?nginx 网页?

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

@overtrue 用你的test.php 开启error_reporting(-1);

echo json_encode($calendar->lunar(2017, 5, 11), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);

直接chrome 访问 test.php ,,,出来的json数据还是1951年,但是不报错了,我用了你最新的代码

from chinese-calendar.

overtrue avatar overtrue commented on July 17, 2024

你先保证你的 mktime 能正确返回吧。。。

from chinese-calendar.

overtrue avatar overtrue commented on July 17, 2024
>>> mktime(0, 0, 0, 1, 30, 1900)
=> -2206483200

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

@overtrue 用你最新的代码为前提

  1. 首先 strtotime('1900-01-30 00:00:00') 依然返回false。
  2. mktime(0, 0, 0, 1, 30, 1900); 也是返回false。
  3. 但是 mktime(0, 0, 0, 1, 30, 2017) 改成2017 可以返回1485705600 正确的时间戳。

怪不怪哈!

from chinese-calendar.

tlerbao avatar tlerbao commented on July 17, 2024

补充 strtotime('2017-01-30 00:00:00') 也可以正常返回正确的时间戳

为何 1900-01-30 00:00:00就false呢 怪了

from chinese-calendar.

overtrue avatar overtrue commented on July 17, 2024

艹,加我 Q 吧

from chinese-calendar.

overtrue avatar overtrue commented on July 17, 2024

44294631

from chinese-calendar.

Related Issues (20)

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.