wearerequired / traduttore

🗼 A WordPress plugin to improve the I18N workflow for your own projects based on @GlotPress.
https://wearerequired.github.io/traduttore/
72 stars 15 forks source link

get_last_updated_time() doesn’t contain timezone #135

Closed MatzeKitt closed 5 years ago

MatzeKitt commented 5 years ago

Issue Overview Currently, get_last_updated_time() doesn’t contain a timezone. It’s always in format YYYY-mm-dd H:i:s. However, if you try to compare it with the current installed translations (e. g. as you do in (traduttore-registry)[https://github.com/wearerequired/traduttore-registry/blob/master/inc/namespace.php#L68]) this test could result in an unexpected result.

I updated a translation in 2018-12-03 11:29:25 local time, which is GMT+1. After updating the translations in my WordPress, their PO-Revision-Date ffrom wp_get_installed_translations() is correctly set to 2018-12-03 10:29:25+0000. However, the translations API does print the following updated date: 2018-12-03 10:29:25. The result was that the update notification for outstanding translations never gets removed.

I double-checked the compare by using the following code:

<?php
$with_timezone = new Datetime( '2018-12-03 10:29:25+0000' );
$without_timezone = new Datetime( '2018-12-03 10:29:25' );

switch ( true ) {
    case $with_timezone > $without_timezone:
        echo 'With > Without';
        break;
    case $with_timezone === $without_timezone:
        echo 'With = Without';
        break;
    case $with_timezone < $without_timezone:
        echo 'With < Without';
        break;
}

Result:

With < Without

Versions

swissspidy commented 5 years ago

Thanks for your report! I'm gonna look into this.

swissspidy commented 5 years ago

136 contains a fix, in case you want to test it before it's being merged.

MatzeKitt commented 5 years ago

Seems to be working fine, thank you! 🙂