original_string: protected function _normalize($date)
      {
          $date = preg_replace('/[^0-9\-]/', '', $date);
          $parts = explode('-', $date);
          $year = date('Y');
          $month = 1;
          $day = 1;
  
          if (!empty($parts[0]) &&
              1 <= intval($parts[0]) &&
              intval($parts[0]) <= 32767
          ) {
              $year = intval($parts[0]);
          }
  
          if (!empty($parts[1]) &&
              1 <= intval($parts[1]) &&
              intval($parts[1]) <= 12
          ) {
              $month = intval($parts[1]);
          }
  
          if (!empty($parts[2]) &&
              1 <= intval($parts[2]) &&
              intval($parts[2]) <= 31
          ) {
              $day = intval($parts[2]);
          }
  
          return date('Y-m-d', strtotime("{$year}-{$month}-{$day}"));
      }
code: protected function _normalize($date)
      {
          $date = preg_replace('/[^0-9\-]/', '', $date);
          $parts = explode('-', $date);
          $year = date('Y');
          $month = 1;
          $day = 1;
  
          if (!empty($parts[0]) &&
              1 <= intval($parts[0]) &&
              intval($parts[0]) <= 32767
          ) {
              $year = intval($parts[0]);
          }
  
          if (!empty($parts[1]) &&
              1 <= intval($parts[1]) &&
              intval($parts[1]) <= 12
          ) {
              $month = intval($parts[1]);
          }
  
          if (!empty($parts[2]) &&
              1 <= intval($parts[2]) &&
              intval($parts[2]) <= 31
          ) {
              $day = intval($parts[2]);
          }
  
          return date('Y-m-d', strtotime("{$year}-{$month}-{$day}"));
      }
code_tokens: protected function _normalize ( $ date ) { $ date = preg_replace ( '/[^0-9\-]/' , '' , $ date ) ; $ parts = explode ( '-' , $ date ) ; $ year = date ( 'Y' ) ; $ month = 1 ; $ day = 1 ; if ( ! empty ( $ parts [ 0 ] ) && 1 <= intval ( $ parts [ 0 ] ) && intval ( $ parts [ 0 ] ) <= 32767 ) { $ year = intval ( $ parts [ 0 ] ) ; } if ( ! empty ( $ parts [ 1 ] ) && 1 <= intval ( $ parts [ 1 ] ) && intval ( $ parts [ 1 ] ) <= 12 ) { $ month = intval ( $ parts [ 1 ] ) ; } if ( ! empty ( $ parts [ 2 ] ) && 1 <= intval ( $ parts [ 2 ] ) && intval ( $ parts [ 2 ] ) <= 31 ) { $ day = intval ( $ parts [ 2 ] ) ; } return date ( 'Y-m-d' , strtotime ( "{$year}-{$month}-{$day}" ) ) ; }
docstring: Normalizes the given date.
  
  @param string $date Date to normalize
  @return string Date formated as `Y-m-d`
docstring_tokens: Normalizes the given date .