original_string: public function define_save_preprocess($data) {
          // Get the current calendar in use - see MDL-18375.
          $calendartype = \core_calendar\type_factory::get_calendar_instance();
  
          // Check if the start year was changed, if it was then convert from the start of that year.
          if ($data->param1 != $data->startyear) {
              $startdate = $calendartype->convert_to_gregorian($data->param1, 1, 1);
          } else {
              $startdate = $calendartype->convert_to_gregorian($data->param1, $data->startmonth, $data->startday);
          }
  
          // Check if the end year was changed, if it was then convert from the start of that year.
          if ($data->param2 != $data->endyear) {
              $stopdate = $calendartype->convert_to_gregorian($data->param2, 1, 1);
          } else {
              $stopdate = $calendartype->convert_to_gregorian($data->param2, $data->endmonth, $data->endday);
          }
  
          $data->param1 = $startdate['year'];
          $data->param2 = $stopdate['year'];
  
          if (empty($data->param3)) {
              $data->param3 = null;
          }
  
          // No valid value in the default data column needed.
          $data->defaultdata = '0';
  
          return $data;
      }
code: public function define_save_preprocess($data) {
          // Get the current calendar in use - see MDL-18375.
          $calendartype = \core_calendar\type_factory::get_calendar_instance();
  
          // Check if the start year was changed, if it was then convert from the start of that year.
          if ($data->param1 != $data->startyear) {
              $startdate = $calendartype->convert_to_gregorian($data->param1, 1, 1);
          } else {
              $startdate = $calendartype->convert_to_gregorian($data->param1, $data->startmonth, $data->startday);
          }
  
          // Check if the end year was changed, if it was then convert from the start of that year.
          if ($data->param2 != $data->endyear) {
              $stopdate = $calendartype->convert_to_gregorian($data->param2, 1, 1);
          } else {
              $stopdate = $calendartype->convert_to_gregorian($data->param2, $data->endmonth, $data->endday);
          }
  
          $data->param1 = $startdate['year'];
          $data->param2 = $stopdate['year'];
  
          if (empty($data->param3)) {
              $data->param3 = null;
          }
  
          // No valid value in the default data column needed.
          $data->defaultdata = '0';
  
          return $data;
      }
code_tokens: public function define_save_preprocess ( $ data ) { // Get the current calendar in use - see MDL-18375. $ calendartype = \ core_calendar \ type_factory :: get_calendar_instance ( ) ; // Check if the start year was changed, if it was then convert from the start of that year. if ( $ data -> param1 != $ data -> startyear ) { $ startdate = $ calendartype -> convert_to_gregorian ( $ data -> param1 , 1 , 1 ) ; } else { $ startdate = $ calendartype -> convert_to_gregorian ( $ data -> param1 , $ data -> startmonth , $ data -> startday ) ; } // Check if the end year was changed, if it was then convert from the start of that year. if ( $ data -> param2 != $ data -> endyear ) { $ stopdate = $ calendartype -> convert_to_gregorian ( $ data -> param2 , 1 , 1 ) ; } else { $ stopdate = $ calendartype -> convert_to_gregorian ( $ data -> param2 , $ data -> endmonth , $ data -> endday ) ; } $ data -> param1 = $ startdate [ 'year' ] ; $ data -> param2 = $ stopdate [ 'year' ] ; if ( empty ( $ data -> param3 ) ) { $ data -> param3 = null ; } // No valid value in the default data column needed. $ data -> defaultdata = '0' ; return $ data ; }
docstring: Preprocess data from the profile field form before
  it is saved.
  
  @param stdClass $data from the add/edit profile field form
  @return stdClass processed data object
docstring_tokens: Preprocess data from the profile field form before it is saved .