-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Support v3.0 for nesbot/carbon.
#6591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
82bad9b to
069b588
Compare
|
https://carbon.nesbot.com/docs/#api-carbon-3 v3.2 版本时,进行挨个比对 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before:
$res = $now->clone()->addSeconds(30)->diffInRealSeconds();
$this->assertSame(30, $res);After:
$res = $now->clone()->addSeconds(30)->floatDiffInRealSeconds();
$this->assertEquals(30, abs(round($res)));Some issues with the change:
- Method
floatDiffInRealSeconds()is not in Carbon 3.x. According to release note of 3.0.0:diffIn*will use thefloatDiffInReal*behavior.floatDiffInReal*()methods were removed.
- Hard to read.
Suggested change:
$this->assertSame(30, (int) $now->diffInSeconds($now->clone()->addSeconds(30), false));or
$this->assertEqualsWithDelta(30, $now->diffInSeconds($now->clone()->addSeconds(30), false), 0.001);|
+1 we need this fix for Laravel-Hyperf
Suggested AdditionsCan you please also update this for
And should probably do the same update for the rest of the codebase?
|
|
@kingIZZZY There are a lot of break changes between Carbon 2.0 and 3.0, and Hyperf will incorporate this PR in the next major release. |
|
Is it not good enough to implement @deminy 's suggested fixes above? Or are there definitely other tests which would fail with carbon 3? So far I just forked my own |
6ac468d to
3f6f103
Compare
This reverts commit 523cb18.
briannesbitt/Carbon#2948
fix #7457