original_string: public function timestamp_to_date_string($time, $format, $timezone, $fixday, $fixhour) {
          global $CFG;
  
          if (empty($format)) {
              $format = get_string('strftimedaydatetime', 'langconfig');
          }
  
          if (!empty($CFG->nofixday)) { // Config.php can force %d not to be fixed.
              $fixday = false;
          } else if ($fixday) {
              $formatnoday = str_replace('%d', 'DD', $format);
              $fixday = ($formatnoday != $format);
              $format = $formatnoday;
          }
  
          // Note: This logic about fixing 12-hour time to remove unnecessary leading
          // zero is required because on Windows, PHP strftime function does not
          // support the correct 'hour without leading zero' parameter (%l).
          if (!empty($CFG->nofixhour)) {
              // Config.php can force %I not to be fixed.
              $fixhour = false;
          } else if ($fixhour) {
              $formatnohour = str_replace('%I', 'HH', $format);
              $fixhour = ($formatnohour != $format);
              $format = $formatnohour;
          }
  
          $time = (int)$time; // Moodle allows rubbish in input...
          $datestring = date_format_string($time, $format, $timezone);
  
          date_default_timezone_set(\core_date::get_user_timezone($timezone));
  
          if ($fixday) {
              $daystring  = ltrim(str_replace(array(' 0', ' '), '', strftime(' %d', $time)));
              $datestring = str_replace('DD', $daystring, $datestring);
          }
          if ($fixhour) {
              $hourstring = ltrim(str_replace(array(' 0', ' '), '', strftime(' %I', $time)));
              $datestring = str_replace('HH', $hourstring, $datestring);
          }
  
          \core_date::set_default_server_timezone();
  
          return $datestring;
      }
code: public function timestamp_to_date_string($time, $format, $timezone, $fixday, $fixhour) {
          global $CFG;
  
          if (empty($format)) {
              $format = get_string('strftimedaydatetime', 'langconfig');
          }
  
          if (!empty($CFG->nofixday)) { // Config.php can force %d not to be fixed.
              $fixday = false;
          } else if ($fixday) {
              $formatnoday = str_replace('%d', 'DD', $format);
              $fixday = ($formatnoday != $format);
              $format = $formatnoday;
          }
  
          // Note: This logic about fixing 12-hour time to remove unnecessary leading
          // zero is required because on Windows, PHP strftime function does not
          // support the correct 'hour without leading zero' parameter (%l).
          if (!empty($CFG->nofixhour)) {
              // Config.php can force %I not to be fixed.
              $fixhour = false;
          } else if ($fixhour) {
              $formatnohour = str_replace('%I', 'HH', $format);
              $fixhour = ($formatnohour != $format);
              $format = $formatnohour;
          }
  
          $time = (int)$time; // Moodle allows rubbish in input...
          $datestring = date_format_string($time, $format, $timezone);
  
          date_default_timezone_set(\core_date::get_user_timezone($timezone));
  
          if ($fixday) {
              $daystring  = ltrim(str_replace(array(' 0', ' '), '', strftime(' %d', $time)));
              $datestring = str_replace('DD', $daystring, $datestring);
          }
          if ($fixhour) {
              $hourstring = ltrim(str_replace(array(' 0', ' '), '', strftime(' %I', $time)));
              $datestring = str_replace('HH', $hourstring, $datestring);
          }
  
          \core_date::set_default_server_timezone();
  
          return $datestring;
      }
code_tokens: public function timestamp_to_date_string ( $ time , $ format , $ timezone , $ fixday , $ fixhour ) { global $ CFG ; if ( empty ( $ format ) ) { $ format = get_string ( 'strftimedaydatetime' , 'langconfig' ) ; } if ( ! empty ( $ CFG -> nofixday ) ) { // Config.php can force %d not to be fixed. $ fixday = false ; } else if ( $ fixday ) { $ formatnoday = str_replace ( '%d' , 'DD' , $ format ) ; $ fixday = ( $ formatnoday != $ format ) ; $ format = $ formatnoday ; } // Note: This logic about fixing 12-hour time to remove unnecessary leading // zero is required because on Windows, PHP strftime function does not // support the correct 'hour without leading zero' parameter (%l). if ( ! empty ( $ CFG -> nofixhour ) ) { // Config.php can force %I not to be fixed. $ fixhour = false ; } else if ( $ fixhour ) { $ formatnohour = str_replace ( '%I' , 'HH' , $ format ) ; $ fixhour = ( $ formatnohour != $ format ) ; $ format = $ formatnohour ; } $ time = ( int ) $ time ; // Moodle allows rubbish in input... $ datestring = date_format_string ( $ time , $ format , $ timezone ) ; date_default_timezone_set ( \ core_date :: get_user_timezone ( $ timezone ) ) ; if ( $ fixday ) { $ daystring = ltrim ( str_replace ( array ( ' 0' , ' ' ) , '' , strftime ( ' %d' , $ time ) ) ) ; $ datestring = str_replace ( 'DD' , $ daystring , $ datestring ) ; } if ( $ fixhour ) { $ hourstring = ltrim ( str_replace ( array ( ' 0' , ' ' ) , '' , strftime ( ' %I' , $ time ) ) ) ; $ datestring = str_replace ( 'HH' , $ hourstring , $ datestring ) ; } \ core_date :: set_default_server_timezone ( ) ; return $ datestring ; }
docstring: Returns a formatted string that represents a date in user time.
  
  Returns a formatted string that represents a date in user time
  <b>WARNING: note that the format is for strftime(), not date().</b>
  Because of a bug in most Windows time libraries, we can't use
  the nicer %e, so we have to use %d which has leading zeroes.
  A lot of the fuss in the function is just getting rid of these leading
  zeroes as efficiently as possible.
  
  If parameter fixday = true (default), then take off leading
  zero from %d, else maintain it.
  
  @param int $time the timestamp in UTC, as obtained from the database
  @param string $format strftime format
  @param int|float|string $timezone the timezone to use
  {@link http://docs.moodle.org/dev/Time_API#Timezone}
  @param bool $fixday if true then the leading zero from %d is removed,
  if false then the leading zero is maintained
  @param bool $fixhour if true then the leading zero from %I is removed,
  if false then the leading zero is maintained
  @return string the formatted date/time
docstring_tokens: Returns a formatted string that represents a date in user time .