function test_array_merge_or() { $one = array('hello', 'there', 'world'); $two = array(); $this->assertEqual(array_merge_or($one, $two), $one); $two = array('hello', 'there'); $this->assertEqual(array_merge_or($one, $two), $one); $one = array(); $two = array('hello', 'there', 'world'); $this->assertEqual(array_merge_or($one, $two), $two); $one = array('hello', 'there'); $two = array('hello', 'there', 'world'); $this->assertEqual(array_merge_or($one, $two), $two); $one = array('hello', NULL, 'world'); $two = array('hello', 'there', 'world'); $this->assertEqual(array_merge_or($one, $two), $two); $one = array('hello', 'there', 'world'); $two = array('hello', NULL, 'world'); $this->assertEqual(array_merge_or($one, $two), $one); $one = array('alpha' => 'hello', 'beta' => 'world'); $two = array('beta' => 'world'); $this->assertEqual(array_merge_or($one, $two), $one); $one = array('alpha' => 'hello', 'beta' => 'world'); $two = array('gamma' => 'there'); $this->assertEqual(array_merge_or($one, $two), array('alpha' => 'hello', 'beta' => 'world', 'gamma' => 'there')); $one = array('alpha' => 'hello', 'beta' => 'world'); $two = array('alpha' => 'hello', 'beta' => 'world', 'gamma' => 'there'); $this->assertEqual(array_merge_or($one, $two), $two); $one = array(0, 1, 2, 3); $two = array(4, 5); $this->assertEqual(array_merge_or($one, $two), $one); $one = array(0, 1, 2, 3); $two = array(4, 5, 6, 7, 8); $this->assertEqual(array_merge_or($one, $two), array(0, 1, 2, 3, 8)); $one = "hello"; $two = array("hello", "there", "world"); $this->assertEqual(array_merge_or($one, $two), $two); $one = array("hello", "there", "world"); $two = "hello"; $this->assertEqual(array_merge_or($one, $two), $one); }
function get_timestamp($from_qs_key = NULL) { $dates = $this->value; if (is_null($dates)) { $dates = $this->default; } if (is_null($dates)) { $dates = $this->range; } $index = 0; if (!is_null($from_qs_key)) { if (is_integer($from_qs_key)) { $index = $from_qs_key; } else { if (string_ends_with($from_qs_key, QC_DATE_RANGE_QS_POSTFIX_END)) { $index = 1; } } } $elements = split('-', $dates[$index]); $defaults = array(0, 0, 0, 0, 0, 0); $elements = array_merge_or($elements, array(0, 0, 0, 0, 0, 0)); return mktime($elements[3], $elements[4], $elements[5], $elements[1], $elements[2], $elements[0]); }