Conversation
Allow parsing of input in suffixed format such as "128M", "1.2G", "340K", "1234.56 MB" for conversion. Allow returning number of bytes without any unit suffix Added support for suffixes EB, ZB, YB. No B/C break hopefully.
…nce this is a JHtml method and not a conversion function we probably can afford little loss of significance.
ac35546 to
3870104
Compare
|
I have tested this item ✅ successfully on 3870104 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11026. |
|
I have apply this sample code in my joomla-cms/components/com_content/views/article/tmpl/default.php file and see the result. It's works successfully. Thanks. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11026. |
|
I have tested this item ✅ successfully on 3870104 This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11026. |
|
RTC - thanks This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11026. |
* Improve JHtmlNumber::bytes Allow parsing of input in suffixed format such as "128M", "1.2G", "340K", "1234.56 MB" for conversion. Allow returning number of bytes without any unit suffix Added support for suffixes EB, ZB, YB. No B/C break hopefully. * Fix unit test failure, the failure is due to float comparison, but since this is a JHtml method and not a conversion function we probably can afford little loss of significance.
|
Dump question but shouldn't it be KiB, MiB, and so on to reflect the correct SI Binary prefix? |
|
@HLeithner not a dumb question but its not standard behaviour to use SI for this |
|
@brianteeman that depends ;-) The ISO/IEC 80000-13:2008 tells us that the standard is to use it ;-) I know that most people don't use it, I don't use it always but try to. But thats not the point. The question is should Joomla should use the/a "official standard" |
|
No we have to use the "real world standard" |
|
I agree with @brianteeman on this. However, we can add another method in the same class that is IEC aware or simply add another parameter to the same method like |
|
@izharaazmi sounds good |
|
Please no more options |
|
i gues @izharaazmi means on code not in the UI 😄 |
|
No point having an option in the code if you have to hack the core to use
it ;)
|
That's exactly what parameters on method calls are for. Not every option has to be something managed via the UI, it could be an option used by developers in their code to change a behavior. |
|
In this case it would be even better to have a option in the ui to switch the complete site from one version to the other and not only a part of the site ;-) |
|
I have added the support for IEC Binary prefixes. It is supposed to be fully B/C. Please test and review. |
* Improve JHtmlNumber::bytes Allow parsing of input in suffixed format such as "128M", "1.2G", "340K", "1234.56 MB" for conversion. Allow returning number of bytes without any unit suffix Added support for suffixes EB, ZB, YB. No B/C break hopefully. * Fix unit test failure, the failure is due to float comparison, but since this is a JHtml method and not a conversion function we probably can afford little loss of significance.
…dency #11026) (#11255) * Show configured upload limit when uploading installer package. Otherwise when uploading a larger file than the configured limit, the page reloads without any information about what went wrong. * Reduce amount of information displayed. * Show upload limits for file input everywhere. Refactor the calculation part to JUtility class.
Summary of Changes
Allow parsing of input in suffixed format such as "128M", "1.2G", "340K", "1234.56 MB" for conversion.
Allow returning number of bytes without any unit suffix
Added support for suffixes EB, ZB, YB.
Testing Instructions
Apparently no straight-forward way to test within Joomla. Please write some code that uses the method
JHtmlNumber::bytes()A sample code is given below (Seeds are taken from Unit Test, you may want to use your own test data):
Expect the following output from above:
PS: There is probably a B/C break due to 'kb' changed to 'kB'. Please advise if that needs to be addressed.