You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expected to get a value of 0 or 0s as I gave it an empty interval.
But I actually get:
1s
I have an application where an empty interval can occur if the user has no hours clocked on a platform. For now I am just using an inline if-check to see if the value is 0, before making the CarbonInterval.
I do think it would make sense to expect CarbonInterval to handle the case of 0 so you don't have to use if-sentences in all fields where a 0-interval could occur.
Thanks!
The text was updated successfully, but these errors were encountered:
But be careful with this last solution, it will also affect all the parts of your app and third-party libraries that call forHumans() or derived methods.
I won't change this for 2.x as it would be a breaking change, but I guess it would be relevant to make this option disabled by default in the next major version so I will keep this issue open for when I'll start it.
kylekatarnls
changed the title
Instantiating CarbonInterval with 0 makes forHumans() report "1s"
⭐ Instantiating CarbonInterval with 0 makes forHumans() report "1s"
Jul 23, 2020
Hello,
I encountered an issue with the following code:
Both with and without
short
modifer.Carbon version: 2.29.1
PHP version: 7.4.2
I expected to get a value of
0
or0s
as I gave it an empty interval.But I actually get:
I have an application where an empty interval can occur if the user has no hours clocked on a platform. For now I am just using an inline if-check to see if the value is 0, before making the CarbonInterval.
I do think it would make sense to expect CarbonInterval to handle the case of 0 so you don't have to use if-sentences in all fields where a 0-interval could occur.
Thanks!
The text was updated successfully, but these errors were encountered: