Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-31636

Comments API needs to allow plugins to set the date format

XMLWordPrintable

    • MOODLE_22_STABLE, MOODLE_24_STABLE
    • MOODLE_24_STABLE
    • Hide

      1) you need to be a developer to test this as this is an API option that is as yet unused within core. Please read through entire test before commencing.
      2) edit the comments block display callback to change the display format in each of the comments
      (New version)
      blocks/comments/lib.php:

      function block_comments_comment_display($comments, $args) {
          if ($args->commentarea != 'page_comments') {
              throw new comment_exception('invalidcommentarea');
          }
          if ($args->itemid != 0) {
              throw new comment_exception('invalidcommentitemid');
          }
          foreach ($comments as $comment) {
              $comment->strftimeformat = get_string('strftimerecentfull', 'langconfig');
          }
          return $comments;
      }
      

      3) Check that the comments in the comment block now display the year as well as the date/time.

      Show
      1) you need to be a developer to test this as this is an API option that is as yet unused within core. Please read through entire test before commencing. 2) edit the comments block display callback to change the display format in each of the comments (New version) blocks/comments/lib.php: function block_comments_comment_display($comments, $args) { if ($args->commentarea != 'page_comments') { throw new comment_exception('invalidcommentarea'); } if ($args->itemid != 0) { throw new comment_exception('invalidcommentitemid'); } foreach ($comments as $comment) { $comment->strftimeformat = get_string('strftimerecentfull', 'langconfig'); } return $comments; } 3) Check that the comments in the comment block now display the year as well as the date/time.

      As illustrated in attached screenshot (taken from http://moodle.org/mod/data/view.php?d=13&rid=4124 ) the dates of comments do not include the year. Comments in the modules and plugins database span over several years, and so including the year would be most helpful.

      I've reported this issue as a moodle.org issue, as I don't know whether all sites would want comment dates to include the year, or whether it is better to keep the dates as short as possible.

      Edited to add: On reflection, I think the dates on comments should be the same as elsewhere in Moodle i.e. including a year, and so have moved the issue from MDLSITE to MDL.

            nebgor Aparup Banerjee
            tsala Helen Foster
            Damyon Wiese Damyon Wiese
            Mark Nelson Mark Nelson
            Votes:
            4 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.