Support v3.0 for nesbot/carbon.#6591
Conversation
82bad9b to
069b588
Compare
|
https://carbon.nesbot.com/docs/#api-carbon-3 v3.2 版本时,进行挨个比对 |
There was a problem hiding this comment.
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