original_string: public function edit_save_data_preprocess($datetime, $datarecord) {
          if (!$datetime) {
              return 0;
          }
  
          if (is_numeric($datetime)) {
              $gregoriancalendar = \core_calendar\type_factory::get_calendar_instance('gregorian');
              $datetime = $gregoriancalendar->timestamp_to_date_string($datetime, '%Y-%m-%d-%H-%M-%S', 99, true, true);
          }
  
          $datetime = explode('-', $datetime);
          // Bound year with start and end year.
          $datetime[0] = min(max($datetime[0], $this->field->param1), $this->field->param2);
  
          if (!empty($this->field->param3) && count($datetime) == 6) {
              return make_timestamp($datetime[0], $datetime[1], $datetime[2], $datetime[3], $datetime[4], $datetime[5]);
          } else {
              return make_timestamp($datetime[0], $datetime[1], $datetime[2]);
          }
      }
code: public function edit_save_data_preprocess($datetime, $datarecord) {
          if (!$datetime) {
              return 0;
          }
  
          if (is_numeric($datetime)) {
              $gregoriancalendar = \core_calendar\type_factory::get_calendar_instance('gregorian');
              $datetime = $gregoriancalendar->timestamp_to_date_string($datetime, '%Y-%m-%d-%H-%M-%S', 99, true, true);
          }
  
          $datetime = explode('-', $datetime);
          // Bound year with start and end year.
          $datetime[0] = min(max($datetime[0], $this->field->param1), $this->field->param2);
  
          if (!empty($this->field->param3) && count($datetime) == 6) {
              return make_timestamp($datetime[0], $datetime[1], $datetime[2], $datetime[3], $datetime[4], $datetime[5]);
          } else {
              return make_timestamp($datetime[0], $datetime[1], $datetime[2]);
          }
      }
code_tokens: public function edit_save_data_preprocess ( $ datetime , $ datarecord ) { if ( ! $ datetime ) { return 0 ; } if ( is_numeric ( $ datetime ) ) { $ gregoriancalendar = \ core_calendar \ type_factory :: get_calendar_instance ( 'gregorian' ) ; $ datetime = $ gregoriancalendar -> timestamp_to_date_string ( $ datetime , '%Y-%m-%d-%H-%M-%S' , 99 , true , true ) ; } $ datetime = explode ( '-' , $ datetime ) ; // Bound year with start and end year. $ datetime [ 0 ] = min ( max ( $ datetime [ 0 ] , $ this -> field -> param1 ) , $ this -> field -> param2 ) ; if ( ! empty ( $ this -> field -> param3 ) && count ( $ datetime ) == 6 ) { return make_timestamp ( $ datetime [ 0 ] , $ datetime [ 1 ] , $ datetime [ 2 ] , $ datetime [ 3 ] , $ datetime [ 4 ] , $ datetime [ 5 ] ) ; } else { return make_timestamp ( $ datetime [ 0 ] , $ datetime [ 1 ] , $ datetime [ 2 ] ) ; } }
docstring: If timestamp is in YYYY-MM-DD or YYYY-MM-DD-HH-MM-SS format, then convert it to timestamp.
  
  @param string|int $datetime datetime to be converted.
  @param stdClass $datarecord The object that will be used to save the record
  @return int timestamp
  @since Moodle 2.5
docstring_tokens: If timestamp is in YYYY - MM - DD or YYYY - MM - DD - HH - MM - SS format then convert it to timestamp .