Code Duplication    Length = 12-12 lines in 3 locations

classes/fields/date.php 1 location

@@ 217-228 (lines=12) @@
214
     * @return mixed|string
215
     * @since 2.0
216
     */
217
    public function pre_save ( $value, $id = null, $name = null, $options = null, $fields = null, $pod = null, $params = null ) {
218
        $format = $this->format( $options );
219
220
        if ( !empty( $value ) && ( 0 == pods_var( self::$type . '_allow_empty', $options, 1 ) || !in_array( $value, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ) ) ) )
221
            $value = $this->convert_date( $value, 'Y-m-d', $format );
222
        elseif ( 1 == pods_var( self::$type . '_allow_empty', $options, 1 ) )
223
            $value = '0000-00-00';
224
        else
225
            $value = date_i18n( 'Y-m-d' );
226
227
        return $value;
228
    }
229
230
    /**
231
     * Customize the Pods UI manage table column output

classes/fields/datetime.php 1 location

@@ 264-275 (lines=12) @@
261
     * @return mixed|string
262
     * @since 2.0
263
     */
264
    public function pre_save ( $value, $id = null, $name = null, $options = null, $fields = null, $pod = null, $params = null ) {
265
        $format = $this->format( $options );
266
267
        if ( !empty( $value ) && ( 0 == pods_var( self::$type . '_allow_empty', $options, 1 ) || !in_array( $value, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ) ) ) )
268
            $value = $this->convert_date( $value, 'Y-m-d H:i:s', $format );
269
        elseif ( 1 == pods_var( self::$type . '_allow_empty', $options, 1 ) )
270
            $value = '0000-00-00 00:00:00';
271
        else
272
            $value = current_time( 'mysql' );
273
274
        return $value;
275
    }
276
277
    /**
278
     * Customize the Pods UI manage table column output

classes/fields/time.php 1 location

@@ 227-238 (lines=12) @@
224
     * @return mixed|string
225
     * @since 2.0
226
     */
227
    public function pre_save ( $value, $id = null, $name = null, $options = null, $fields = null, $pod = null, $params = null ) {
228
        $format = $this->format( $options );
229
230
        if ( !empty( $value ) && ( 0 == pods_var( self::$type . '_allow_empty', $options, 1 ) || !in_array( $value, array( '0000-00-00', '0000-00-00 00:00:00', '00:00:00' ) ) ) )
231
            $value = $this->convert_date( $value, 'H:i:s', $format );
232
        elseif ( 1 == pods_var( self::$type . '_allow_empty', $options, 1 ) )
233
            $value = '00:00:00';
234
        else
235
            $value = date_i18n( 'H:i:s' );
236
237
        return $value;
238
    }
239
240
    /**
241
     * Customize the Pods UI manage table column output