User tests: Successful: Unsuccessful:
Reduce unit tests time a little further, but removing to 1 seconds sleep in JFactoryTest::testGetDateNow
(one line changed).
Unit tested passed.
Code review
None.
Status | New | ⇒ | Pending |
Category | ⇒ | Unit Tests |
Labels |
Added:
?
?
|
how do you test this at console? what's the command? i only tested on online travis.
Also i think DateTime supports microseconds since php 5.2.2 ->format('u')
On local computer type command:
php -a
You should see:
$ php -a
Interactive mode enabledphp >
You can test online at http://sandbox.onlinephpfunctions.com/code/357b85e44650699c371f7c947a800b6e102d922f
I tought JDate was extended to have microseconds too
So 'now' for Joomla can be 0.99 seconds ago
We could do something like this here https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/date/date.php#L107 for joomla to have the correct 'now' up to microsecond but i really don't know the impacts of this.
if ($date === 'now')
{
$now = microtime(true);
$micro = sprintf("%06d", ($now - floor($now)) * 1000000);
$date = date('Y-m-d H:i:s.' . $micro, $now);
}
But, for now the 'now' is in seconds.
i will change this PR to 1 second them.
Since JDate
is extending PHP's native DateTime
, I wouldn't do too much with its internal data structure, especially if it causes weird side effects or breakage of features using the native class.
Does adding microseconds when constructing a DateTime causes weird side effects or breakage of features using the native class
?
I don't know, I don't generally work with microseconds when using time based data (at least I haven't had a use case for it in 5+ years).
i actually use microseconds a lot for performance tests.
Quick glance through the PHP docs says yes it is supported (use u
in your format strings when formatting DateTime
objects). So I guess it's fine.
Title |
|
I have tested this item
Code review.
1 second less is OK.
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-09-03 11:36:28 |
Closed_By | ⇒ | wilsonge |
Code review failed.
Datetime
precision is 1 second.test at console:
$a = new Datetime();usleep(1);$b = new Datetime();
var_dump($a == $b); // bool(true)
and:
$a = new Datetime();sleep(1);$b = new Datetime();
var_dump($a == $b); // bool(false)