@@ 402-418 (lines=17) @@ | ||
399 | * |
|
400 | * @return DateTime |
|
401 | */ |
|
402 | public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current) |
|
403 | { |
|
404 | // if $time_to_set_string is datetime object, then let's use it to set the parse array. |
|
405 | // Otherwise parse the string. |
|
406 | if ($time_to_set_string instanceof DateTime) { |
|
407 | $parsed = array( |
|
408 | 'hour' => $time_to_set_string->format('H'), |
|
409 | 'minute' => $time_to_set_string->format('i'), |
|
410 | 'second' => $time_to_set_string->format('s') |
|
411 | ); |
|
412 | } else { |
|
413 | //parse incoming string |
|
414 | $parsed = date_parse_from_format($this->_time_format, $time_to_set_string); |
|
415 | } |
|
416 | ||
417 | //make sure $current is in the correct timezone. |
|
418 | $current->setTimezone($this->_DateTimeZone); |
|
419 | ||
420 | return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']); |
|
421 | } |
|
@@ 432-448 (lines=17) @@ | ||
429 | * |
|
430 | * @return DateTime |
|
431 | */ |
|
432 | public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current) |
|
433 | { |
|
434 | // if $time_to_set_string is datetime object, then let's use it to set the parse array. |
|
435 | // Otherwise parse the string. |
|
436 | if ($date_to_set_string instanceof DateTime) { |
|
437 | $parsed = array( |
|
438 | 'year' => $date_to_set_string->format('Y'), |
|
439 | 'month' => $date_to_set_string->format('m'), |
|
440 | 'day' => $date_to_set_string->format('d') |
|
441 | ); |
|
442 | } else { |
|
443 | //parse incoming string |
|
444 | $parsed = date_parse_from_format($this->_date_format, $date_to_set_string); |
|
445 | } |
|
446 | ||
447 | //make sure $current is in the correct timezone |
|
448 | $current->setTimezone($this->_DateTimeZone); |
|
449 | ||
450 | return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']); |
|
451 | } |