-
Notifications
You must be signed in to change notification settings - Fork 5
Suggestion for displaying Dates in view updates files #52
Conversation
@@ -90,7 +90,7 @@ protected function storeFileInfo($path, $name, $template) | |||
|
|||
if ($coreFile = $this->getCoreFile($path . $name, $template->client_id)) | |||
{ | |||
$temp->modifiedDate = date("y-m-d h:i:s.u", filemtime($coreFile)); | |||
$temp->modifiedDate = date("Y-m-d H:i:s", filemtime($coreFile)); |
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.
This is not necessary here. I only add it for making the date similar to use the format in Joomla\CMS\Date\Date;
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.
Agree with this we can use :)
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.
Now this is fine.
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.
What is missing here is timezone conversion. I'm not sure in what for a timezone the file timestamps are defined but date takes into account the server timezone and we need to store the dates in UTC.
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.
@laoneo Yes, we are storing DateTimeZone
of the server in UTC.
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.
@astridx Can you please remove $temp->modifiedDate
because we no longer using this right ?
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.
And, remove unset($after[$i]->coreFile);
in override plugin line 145.
|
||
if (empty($pk->modifiedDate)) | ||
$pk->modifiedDate = '0000-00-00 00:00:00'; | ||
if (!empty($pk->modifiedDate)) |
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.
In this case, we never get $pk->modifiedDate
empty right? So, modifiedDate is always $createdDate
?
In without this PR or previous. When the core file is removed not updated. We did not get modified date because core file is removed right ?
Then, we show the in override list that core file removed
.
So, i think just add $pk->modifiedDate = '0000-00-00 00:00:00';
after if statment or condition . Then, its fine ?
@Anu1601CS Many Thanks. I had not considered the case that the file was deleted. Now it should be OK, right? |
$tz = new \DateTimeZone(Factory::getApplication()->get('offset')); | ||
$date = new Date('now'); | ||
$date->setTimezone($tz); | ||
$createdDate = $date->toSql(true); | ||
|
||
if (empty($pk->modifiedDate)) |
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.
And, here you can check empty of $pk->coreFile
right?
@Anu1601CS We can make an issue for deleting unnecessary program code. |
@astridx If you are not free. So, can I make changes to it ? |
@Anu1601CS Yes, of course |
@astridx Done! I hope, I did not make any mistake. |
{ | ||
$pk->modifiedDate = '0000-00-00 00:00:00'; | ||
$modifiedDate = '0000-00-00 00:00:00'; |
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.
Here we can take the null date from the database driver to stay on the safe side.
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.
@astridx Can you please take a look?
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.
$tz = new \DateTimeZone(Factory::getApplication()->get('offset')); | ||
$date = new Date('now'); | ||
$date->setTimezone($tz); | ||
$createdDate = $date->toSql(true); |
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.
This has to be stored in UTC or not?
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 think we can store the time in the user time zone.
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.
Why? How do you want to handle then different timezones and DST?
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.
@astridx ?
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.
This has to be stored in UTC or not?
If I am right, it is automatically UTC, as UTC is the default time zone in Joomla\CMS\Date\Date (/libraries/src/Date/Date.php).
@laoneo Can you please test this PR ? |
Why did you merge this one? It is wrong, dates should never be stored in the user timezone. |
@laoneo How do you like it? Should we store the UTC value in the database and convert it only for display? Or should we even display the UTC value? |
@astridx I store UTC value in database. |
That's what Joomla does, dates are stored in UTC and are displayed in the timezone of the user. |
@laoneo OK. I will change it. I will do this in a new PR, ok? Or should I revert the old one? |
There are two things here to test:
You can easily test it by changing the Joomla timezone to something like Sidney and the user timezone to something completely different. And when DSt kicks in, we are screwed even more. I wen through all of that with DPCalendar 🙈 |
* Load correct core files of override files (#2) Start implements loadcorefile() in administrator/components/com_templates/Model/TemplateModel.php * CS (#3) Coding Standards * codingstandards * codingstandards (#4) * Test (#6) Phase 2 (2 part) Mechanism to find correct core file and implementation. * Remove Notice: Only available for html-folder * Remove Warning if core file not found (#11) Thanks. So one part of the issue #12 is done. * Implement the diff view in template manager Implement the diff view in template manager * coding standard (#17) * fix diff (#18) Fix bug in path in case of administrator template override. Fix bug in path in case of administrator template override. * Notification after update and TEST (#16) Find changed files of overridden files and show message. * coding standard (#21) * correction * correction (#26) * Correcthtmlpath (#27) * correction * change oldhtml to newhtml * List of updated override files. (#30) * addcss (#34) * Final Product (#39) Core and Diff view Updated override history list. Quick icon notification plugin. Override control plugin. * save 3 lines :) * New feature show status. (#47) show status in com_template view templates * link * corrected namespace * Button to Switch (#35) * wip add Switcher * wip style switcher * wip style switch make inline and change on off text * wip start with js * wip js * wip delete buttons and make js more robust * wip save to storage * wip delete old code * wip * wip lint * wip css * set default value for switcher * wip make switcher blue * wip * wip * build * correct names * create new functions * fist test code * use onchange * undo installer.min.js * add forgotten new line at the end of css file * correct align * correct compare.es6 - only deleted the toggle part * correct compare.js - only deleted the toggle part * wip * reduce timeout * wrap in funcitons * wip * add use strict to both js-files(compare and toggle) * add the timeout value of 500 again, because 200 are not enought in my case * use css class 'active' for toggle views * add strict * time out for editor * wip * improvments use newActive and switch * correction * width of switcher-spans * correct align * do not use global * wip * removed timeouts * JTEXT to TEXT * forgotton last line * deleted duplicated comments * css fix align * use unnamed functions in es6 * Sql files for fix database (#50) * sql files for database fix * delete space * Suggestion for displaying Dates in view updates files (#52) Correct Dates and do not use date of file any more * Store Date as UTC and show it in server time zone (#57) * modified and created date are created and stored in UTC * convert dates for displaying in model * spar a loop * normalize timezone in view * use language constants for dateformat * JToolbarHelper to ToolbarHelper * CS * namespace * plural * name * clean * text * fx * sin * files * s * Suggestion for language strings (#60) * language strings * correct typo * delete media folder plg_quickicon * add folder plg_quickicon to build/media_src * delete files in media folder * Move media folder - System (#66) * multi * cs * delete files in media folder for joomla toolbar (#67) * Fix button switchers style. (#70) * button * CS * changed uitab.addTab for updated files * Bring back core.js changes. (#69) * core.js * const * fix * form * core * hound * CS * scopr * grid * alpha * cs * lang * only override file * lang * override lang installer * Cs * sub * Update list of core extensions (#71) * Language changes (#76) * update * Update en-GB.com_templates.ini * override JLIB_HTML_PUBLISH_ITEM this is the hover text on the publish icon in the list of files * Change icon (#74) change the icon to use an outline for more consistency * lang * not core (#75) * not core * Update en-GB.plg_installer_override.ini * namespace * cs * Updated files (#82) * Update default_updated_files.php * Update en-GB.com_templates.ini * Update en-GB.com_templates.ini (#81) * Update en-GB.plg_quickicon_overridecheck.ini (#80) * Update en-GB.plg_quickicon_overridecheck.ini (#79) * remove space (#78) * Update en-GB.plg_quickicon_overridecheck.ini * Update en-GB.plg_quickicon_overridecheck.sys.ini * remove hardcoded id * null get function * state * clean * More changes "core" to "original" (#85) * cs * update * plural
Pull Request for Issue #42.
Summary of Changes
Testing Instructions
Expected result
Creation date and modified date are the same in view updated files in case of the first update.
![templates customise cassiopeia test administration 29](https://user-images.githubusercontent.com/9974686/43021273-624720f2-8c63-11e8-9541-549f915129f0.png)
Modified date is the of the last update, in case of many updates.
![templates customise cassiopeia test administration 30](https://user-images.githubusercontent.com/9974686/43021286-6a06b44c-8c63-11e8-9796-52996772923a.png)
Actual result
You have a delay depending on your time zone for creation date.