diff --git a/includes/admin/importers/class-sp-event-importer.php b/includes/admin/importers/class-sp-event-importer.php index 01d46575..1ddcfd8a 100644 --- a/includes/admin/importers/class-sp-event-importer.php +++ b/includes/admin/importers/class-sp-event-importer.php @@ -58,6 +58,7 @@ if ( class_exists( 'WP_Importer' ) ) { $event_format = ( empty( $_POST['sp_format'] ) ? false : $_POST['sp_format'] ); $league = ( sp_array_value( $_POST, 'sp_league', '-1' ) == '-1' ? false : $_POST['sp_league'] ); $season = ( sp_array_value( $_POST, 'sp_season', '-1' ) == '-1' ? false : $_POST['sp_season'] ); + $date_format = ( empty( $_POST['sp_date_format'] ) ? 'yyyy/mm/dd' : $_POST['sp_date_format'] ); // Get labels from result and performance post types $result_labels = sp_get_var_labels( 'sp_result' ); @@ -118,8 +119,24 @@ if ( class_exists( 'WP_Importer' ) ) { // List event columns list( $date, $time, $venue ) = $event; - // Format date by replacing slashes with dashes + // Format date $date = str_replace( '/', '-', trim( $date ) ); + $date_array = explode( '-', $date ); + switch ( $date_format ): + case 'dd/mm/yyyy': + $date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' . + substr( str_pad( sp_array_value( $date_array, 1, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ) . '-' . + substr( str_pad( sp_array_value( $date_array, 0, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ); + break; + case 'mm/dd/yyyy': + $date = substr( str_pad( sp_array_value( $date_array, 2, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' . + substr( str_pad( sp_array_value( $date_array, 0, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ) . '-' . + substr( str_pad( sp_array_value( $date_array, 1, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ); + default: + $date = substr( str_pad( sp_array_value( $date_array, 0, '0000' ), 4, '0', STR_PAD_LEFT ), 0, 4 ) . '-' . + substr( str_pad( sp_array_value( $date_array, 1, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ) . '-' . + substr( str_pad( sp_array_value( $date_array, 2, '00' ), 2, '0', STR_PAD_LEFT ), 0, 2 ); + endswitch; // Add time to date if given if ( ! empty( $time ) ): @@ -443,26 +460,6 @@ if ( class_exists( 'WP_Importer' ) ) { ?> - - - - + + + +
- - -
-
    -
  • - -
  • -
  • - -
  • -
  • - -
  • -
-
-

@@ -504,6 +501,26 @@ if ( class_exists( 'WP_Importer' ) ) { endif; ?>
+ + +
+
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
+