|
@@ 387-403 (lines=17) @@
|
| 384 |
|
* @param DateTime $current current DateTime object for the datetime field |
| 385 |
|
* @return DateTime |
| 386 |
|
*/ |
| 387 |
|
public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current) |
| 388 |
|
{ |
| 389 |
|
// if $time_to_set_string is datetime object, then let's use it to set the parse array. |
| 390 |
|
// Otherwise parse the string. |
| 391 |
|
if ($time_to_set_string instanceof DateTime) { |
| 392 |
|
$parsed = array( |
| 393 |
|
'hour' => $time_to_set_string->format('H'), |
| 394 |
|
'minute' => $time_to_set_string->format('i'), |
| 395 |
|
'second' => $time_to_set_string->format('s'), |
| 396 |
|
); |
| 397 |
|
} else { |
| 398 |
|
//parse incoming string |
| 399 |
|
$parsed = date_parse_from_format($this->_time_format, $time_to_set_string); |
| 400 |
|
} |
| 401 |
|
|
| 402 |
|
//make sure $current is in the correct timezone. |
| 403 |
|
$current->setTimezone($this->_DateTimeZone); |
| 404 |
|
|
| 405 |
|
return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']); |
| 406 |
|
} |
|
@@ 416-432 (lines=17) @@
|
| 413 |
|
* @param DateTime $current current DateTime object for the datetime field |
| 414 |
|
* @return DateTime |
| 415 |
|
*/ |
| 416 |
|
public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current) |
| 417 |
|
{ |
| 418 |
|
// if $time_to_set_string is datetime object, then let's use it to set the parse array. |
| 419 |
|
// Otherwise parse the string. |
| 420 |
|
if ($date_to_set_string instanceof DateTime) { |
| 421 |
|
$parsed = array( |
| 422 |
|
'year' => $date_to_set_string->format('Y'), |
| 423 |
|
'month' => $date_to_set_string->format('m'), |
| 424 |
|
'day' => $date_to_set_string->format('d'), |
| 425 |
|
); |
| 426 |
|
} else { |
| 427 |
|
//parse incoming string |
| 428 |
|
$parsed = date_parse_from_format($this->_date_format, $date_to_set_string); |
| 429 |
|
} |
| 430 |
|
|
| 431 |
|
//make sure $current is in the correct timezone |
| 432 |
|
$current->setTimezone($this->_DateTimeZone); |
| 433 |
|
|
| 434 |
|
return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']); |
| 435 |
|
} |