Code Duplication    Length = 17-17 lines in 2 locations

core/db_models/fields/EE_Datetime_Field.php 2 locations

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