-
-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace Date Format String Literals With Existing Constants #2592
Replace Date Format String Literals With Existing Constants #2592
Conversation
…f the existing constants (db vs non-db context).
# Conflicts: # app/code/core/Mage/Adminhtml/Block/Sitemap/Grid/Renderer/Time.php
@@ -128,7 +128,7 @@ public function add($severity, $title, $description, $url = '', $isInternal = tr | |||
if (is_array($description)) { | |||
$description = '<ul><li>' . implode('</li><li>', $description) . '</li></ul>'; | |||
} | |||
$date = date('Y-m-d H:i:s'); | |||
$date = date(Varien_Db_Adapter_Pdo_Mysql::TIMESTAMP_FORMAT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd use Varien_Db_Adapter_Pdo_Mysql ::DATETIME_FORMAT since the name is more similar to the meaning, and the constant is the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about those two. You are completely right, there is the third constant (besides the one in Varien_Date
) that also defines a format and it is the same as TIMESTAMP_FORMAT
. The other one is currently unused if the IDE is to be believed.
I picked TIMESTAMP_FORMAT
for one main reason: the datrabase columns I checked all have the type timestamp not the type datetime which both are present in MySQL, are similar but have distinguishing characteristics. I totally think that the format of both will never be different though.
In all cases I checked there has been no column with datetime type. For the specific case this is true as well .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow, they've a timestamp type but the php formatting is YMDIms?? auch
fixed conflict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll approve although this timestamp thing still makes me wonder
Description (*)
#2474 inspired me to search for usages of string literals containing the datetime format
'Y-m-d H:i:s'
that is defined already as constant multiple times.Varien_Db_Adapter_Pdo_Mysql::TIMESTAMP_FORMAT
Varien_Date::DATETIME_PHP_FORMAT
Imo to have multiple constants with the same content is fine because the constants have different contexts. This PR replaces string literals in each case with one of those two constants. I selected by context foreach case. I ensured that the corresponding columns in database have the timestamp type.
Contribution checklist (*)