Comments (37)
😆 无 fuck 说,肯定是 bug 了,但是这会儿我是真忙不过来搞它。请给我一些时间。
from chinese-calendar.
@overtrue 好,不急,那我就等了,找了N个农历阳历转换的类库,终于发现安神有这个轮子,还是安神的代码长的好看。
我还在 laravelChina 发了个贴,您忙完可以一并解答我这个菜鸡。
https://laravel-china.org/topics/4557/some-of-the-problems-of-soothing-chinese-calendar-ask-for-advice
from chinese-calendar.
$result = $calendar->lunar(2017, 4, 10); // 阴历 这个确实有问题
from chinese-calendar.
@momosc 有问题是的确的,但是安神 没有时间管这个轮子哈。
from chinese-calendar.
@overtrue 距离上次commit 已经一个月了,安神咱百忙之中家装抽空更新一下这个包呗,哪怕是修复一下bug。代码写的渣,实在不忍pr啊。
from chinese-calendar.
@tlerbao 为啥我的是
from chinese-calendar.
@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.
@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.
对啊,我就是这样用的啊
from chinese-calendar.
你的 PHP 版本是?
from chinese-calendar.
@overtrue
Win10
php 5.6.27-nts + nginx
from chinese-calendar.
靠,我的 PHP 7 是正常的,我换 5.6 试试
from chinese-calendar.
@tlerbao 我的 5.6 也正常 😆
from chinese-calendar.
@overtrue 难道我活见鬼了?
from chinese-calendar.
@overtrue 主要上面也有个朋友说有问题哈
from chinese-calendar.
建议你先更新看看,我觉得可能你装了旧版哈哈
from chinese-calendar.
@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.
@overtrue 安神,有头绪么?是我的问题,还是怎样?
from chinese-calendar.
我找其它人试一下
from chinese-calendar.
@tlerbao 测试了一下是没问题的
from chinese-calendar.
@jcc 我去 那我活见鬼了?请问您是 win 还是mac php版本?
from chinese-calendar.
@overtrue 很怪 阳历就非常正常 阴历就都1951-x-x
$calendar->solar(2017, 5, 11); // 阳历就非常正常
$calendar->lunar(2017, 5, 11) // 阴历就1951年x月x日,醉醉的啊。
from chinese-calendar.
@overtrue 我调试了一下发现 645 行
$startTimestamp = mktime(0, 0, 0, 1, 30, 1900);
这个$startTimestamp 是个bool(false) ,这似乎不正常。
from chinese-calendar.
@tlerbao 把你的错误打开 error_reporting(-1)
from chinese-calendar.
@tlerbao 更新版本
from chinese-calendar.
@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.
@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.
所以需要设置时区嘛
from chinese-calendar.
@overtrue 设置时区不报错了,但依然是1951年。。。菜的抠脚啊我
from chinese-calendar.
你是如何测试的?nginx 网页?
from chinese-calendar.
@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.
你先保证你的 mktime 能正确返回吧。。。
from chinese-calendar.
>>> mktime(0, 0, 0, 1, 30, 1900)
=> -2206483200
from chinese-calendar.
@overtrue 用你最新的代码为前提
- 首先 strtotime('1900-01-30 00:00:00') 依然返回false。
- mktime(0, 0, 0, 1, 30, 1900); 也是返回false。
- 但是 mktime(0, 0, 0, 1, 30, 2017) 改成2017 可以返回1485705600 正确的时间戳。
怪不怪哈!
from chinese-calendar.
补充 strtotime('2017-01-30 00:00:00') 也可以正常返回正确的时间戳
为何 1900-01-30 00:00:00就false呢 怪了
from chinese-calendar.
艹,加我 Q 吧
from chinese-calendar.
44294631
from chinese-calendar.
Related Issues (20)
- 实例化在centos上页面找不到了
- 阳历转阴历日期bug
- 生肖计算不对 HOT 2
- Gregorian to Chinese ≠ Chinese to Gregorian HOT 2
- DateTime diff使用RPC时区计算days错误
- Parse error ??? HOT 4
- 阳历转阴历报错--bug HOT 1
- 大佬,该更新2020节假日了
- 實驗用在MediaWiki的Extension上
- 1933年0x06e95错误 应该为 0x16a95;
- 你可能注意到,含时间的农历结果怎么是 四月十一 而不是 四月初十,具体见 #13 HOT 1
- I found some php version get your dateDiff not correctly HOT 3
- 错误太多了,写了个循环从 1900 到 2099 随便填的月份不匹配的一大片,和百度万年历对比,很多农历日期慢一天 HOT 3
- 干支的年份计算错了 2022-01-20 是辛丑年 算成了壬寅年
- Missing MIT-Licence-text HOT 1
- **实行夏令时期间农历计算错误 HOT 7
- is_same_year 是否是当年, 返回错误, 会永远为true HOT 2
- 八字计算:日柱和时柱结果错误 HOT 1
- 大佬 这个仓库还在维护吗?公历转农历 生肖有些错误 HOT 3
- Bug with some date HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chinese-calendar.