Code Duplication    Length = 17-17 lines in 2 locations

core/db_models/fields/EE_Datetime_Field.php 2 locations

@@ 383-399 (lines=17) @@
380
     * @param DateTime        $current            current DateTime object for the datetime field
381
     * @return DateTime
382
     */
383
    public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current)
384
    {
385
        // if $time_to_set_string is datetime object, then let's use it to set the parse array.
386
        // Otherwise parse the string.
387
        if ($time_to_set_string instanceof DateTime) {
388
            $parsed = array(
389
                'hour'   => $time_to_set_string->format('H'),
390
                'minute' => $time_to_set_string->format('i'),
391
                'second' => $time_to_set_string->format('s'),
392
            );
393
        } else {
394
            // parse incoming string
395
            $parsed = date_parse_from_format($this->_time_format, $time_to_set_string);
396
        }
397
        EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone);
398
        return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']);
399
    }
400
401
402
    /**
@@ 409-425 (lines=17) @@
406
     * @param DateTime        $current            current DateTime object for the datetime field
407
     * @return DateTime
408
     */
409
    public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current)
410
    {
411
        // if $time_to_set_string is datetime object, then let's use it to set the parse array.
412
        // Otherwise parse the string.
413
        if ($date_to_set_string instanceof DateTime) {
414
            $parsed = array(
415
                'year'  => $date_to_set_string->format('Y'),
416
                'month' => $date_to_set_string->format('m'),
417
                'day'   => $date_to_set_string->format('d'),
418
            );
419
        } else {
420
            // parse incoming string
421
            $parsed = date_parse_from_format($this->_date_format, $date_to_set_string);
422
        }
423
        EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone);
424
        return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']);
425
    }
426
427
428
    /**