public static function makeFromDateTime($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timezone = null)
{
$date = new static(null, $timezone);
$date->setDate($year ?: $date->getYear(), $month ?: $date->getMonth(), $day ?: $date->getDay());
// If no hour was given then we'll default the minute and second to the current
// minute and second. If a date was given and minute or second are null then
// we'll set them to 0, mimicking PHPs behaviour.
if (is_null($hour)) {
$minute = $minute ?: $date->getMinute();
$second = $second ?: $date->getSecond();
} else {
$minute = $minute ?: 0;
$second = $second ?: 0;
}
$date->setTime($hour ?: $date->getHour(), $minute, $second);
return $date;
}