本文整理匯總了PHP中TimeExpressionParser::getTimes方法的典型用法代碼示例。如果您正苦於以下問題:PHP TimeExpressionParser::getTimes方法的具體用法?PHP TimeExpressionParser::getTimes怎麽用?PHP TimeExpressionParser::getTimes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TimeExpressionParser
的用法示例。
在下文中一共展示了TimeExpressionParser::getTimes方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testTimes
public function testTimes()
{
$o_tep = new TimeExpressionParser();
$o_tep->setLanguage('en_US');
$vb_res = $o_tep->parseTime('10:55pm');
$va_parse = $o_tep->getTimes();
$this->assertEquals($va_parse['start'], 82500);
$this->assertEquals($va_parse['end'], 82500);
$this->assertEquals($va_parse[0], 82500);
$this->assertEquals($va_parse[1], 82500);
$vb_res = $o_tep->parseTime('22:55');
$va_parse = $o_tep->getTimes();
$this->assertEquals($va_parse['start'], 82500);
$this->assertEquals($va_parse['end'], 82500);
$this->assertEquals($va_parse[0], 82500);
$this->assertEquals($va_parse[1], 82500);
$vb_res = $o_tep->parseTime('22:55:15');
$va_parse = $o_tep->getTimes();
$this->assertEquals($va_parse['start'], 82515);
$this->assertEquals($va_parse['end'], 82515);
$this->assertEquals($va_parse[0], 82515);
$this->assertEquals($va_parse[1], 82515);
}
示例2: set
//.........這裏部分代碼省略.........
if ($vs_cur_value != $va_timestamps["start"]) {
$this->_FIELD_VALUES[$vs_field] = $va_timestamps["start"];
$this->_FIELD_VALUE_CHANGED[$vs_field] = true;
}
} else {
$va_timestamps = $o_tep->getUnixTimestamps();
if ($va_timestamps[0] == -1) {
$this->postError(1830, $o_tep->getParseErrorMessage(), 'BaseModel->set()', $this->tableName() . '.' . $vs_field);
return false;
}
if ($vs_cur_value != $va_timestamps["start"]) {
$this->_FIELD_VALUES[$vs_field] = $va_timestamps["start"];
$this->_FIELD_VALUE_CHANGED[$vs_field] = true;
}
}
}
}
break;
case FT_TIME:
if ($this->DIRECT_TIMES || $pa_options["SET_DIRECT_TIME"]) {
$this->_FIELD_VALUES[$vs_field] = $vm_value;
} else {
if (!$vm_value && $this->FIELDS[$vs_field]["IS_NULL"]) {
if ($vs_cur_value) {
$this->_FIELD_VALUE_CHANGED[$vs_field] = true;
}
$this->_FIELD_VALUES[$vs_field] = null;
} else {
$o_tep = new TimeExpressionParser();
if (!$o_tep->parseTime($vm_value)) {
$this->postError(1805, $o_tep->getParseErrorMessage(), 'BaseModel->set()', $this->tableName() . '.' . $vs_field);
return false;
}
$va_times = $o_tep->getTimes();
if ($vs_cur_value != $va_times['start']) {
$this->_FIELD_VALUES[$vs_field] = $va_times['start'];
$this->_FIELD_VALUE_CHANGED[$vs_field] = true;
}
}
}
break;
case FT_TIMESTAMP:
# can't set timestamp
break;
case FT_DATERANGE:
case FT_HISTORIC_DATERANGE:
$vs_start_field_name = $this->getFieldInfo($vs_field, "START");
$vs_end_field_name = $this->getFieldInfo($vs_field, "END");
$vn_start_date = isset($this->_FIELD_VALUES[$vs_start_field_name]) ? $this->_FIELD_VALUES[$vs_start_field_name] : null;
$vn_end_date = isset($this->_FIELD_VALUES[$vs_end_field_name]) ? $this->_FIELD_VALUES[$vs_end_field_name] : null;
if ($this->DIRECT_DATETIMES || $pa_options["SET_DIRECT_DATE"]) {
if (is_array($vm_value) && sizeof($vm_value) == 2 && $vm_value[0] <= $vm_value[1]) {
if ($vn_start_date != $vm_value[0]) {
$this->_FIELD_VALUE_CHANGED[$vs_field] = true;
$this->_FIELD_VALUES[$vs_start_field_name] = $vm_value[0];
}
if ($vn_end_date != $vm_value[1]) {
$this->_FIELD_VALUE_CHANGED[$vs_field] = true;
$this->_FIELD_VALUES[$vs_end_field_name] = $vm_value[1];
}
} else {
$this->postError(1100, _t("Invalid direct date values"), "BaseModel->set()", $this->tableName() . '.' . $vs_field);
}
} else {
if (!$vm_value && $this->FIELDS[$vs_field]["IS_NULL"]) {
if ($vn_start_date || $vn_end_date) {
示例3: set
//.........這裏部分代碼省略.........
if ($vs_cur_value != $va_timestamps["start"]) {
$this->_FIELD_VALUES[$vs_field] = $va_timestamps["start"];
$this->_FIELD_VALUE_CHANGED[$vs_field] = true;
}
} else {
$va_timestamps = $o_tep->getUnixTimestamps();
if ($va_timestamps[0] == -1) {
$this->postError(1830, $o_tep->getParseErrorMessage(), 'BaseModel->set()');
return false;
}
if ($vs_cur_value != $va_timestamps["start"]) {
$this->_FIELD_VALUES[$vs_field] = $va_timestamps["start"];
$this->_FIELD_VALUE_CHANGED[$vs_field] = true;
}
}
}
}
break;
case FT_TIME:
if ($this->DIRECT_TIMES || $pa_options["SET_DIRECT_TIME"]) {
$this->_FIELD_VALUES[$vs_field] = $vm_value;
} else {
if (!$vm_value && $this->FIELDS[$vs_field]["IS_NULL"]) {
if ($vs_cur_value) {
$this->_FIELD_VALUE_CHANGED[$vs_field] = true;
}
$this->_FIELD_VALUES[$vs_field] = null;
} else {
$o_tep = new TimeExpressionParser();
if (!$o_tep->parseTime($vm_value)) {
$this->postError(1805, $o_tep->getParseErrorMessage(), 'BaseModel->set()');
return false;
}
$va_times = $o_tep->getTimes();
if ($vs_cur_value != $va_times['start']) {
$this->_FIELD_VALUES[$vs_field] = $va_times['start'];
$this->_FIELD_VALUE_CHANGED[$vs_field] = true;
}
}
}
break;
case FT_TIMESTAMP:
# can't set timestamp
break;
case FT_DATERANGE:
case FT_HISTORIC_DATERANGE:
$vs_start_field_name = $this->getFieldInfo($vs_field, "START");
$vs_end_field_name = $this->getFieldInfo($vs_field, "END");
$vn_start_date = isset($this->_FIELD_VALUES[$vs_start_field_name]) ? $this->_FIELD_VALUES[$vs_start_field_name] : null;
$vn_end_date = isset($this->_FIELD_VALUES[$vs_end_field_name]) ? $this->_FIELD_VALUES[$vs_end_field_name] : null;
if ($this->DIRECT_DATETIMES || $pa_options["SET_DIRECT_DATE"]) {
if (is_array($vm_value) && sizeof($vm_value) == 2 && $vm_value[0] <= $vm_value[1]) {
if ($vn_start_date != $vm_value[0]) {
$this->_FIELD_VALUE_CHANGED[$vs_field] = true;
$this->_FIELD_VALUES[$vs_start_field_name] = $vm_value[0];
}
if ($vn_end_date != $vm_value[1]) {
$this->_FIELD_VALUE_CHANGED[$vs_field] = true;
$this->_FIELD_VALUES[$vs_end_field_name] = $vm_value[1];
}
} else {
$this->postError(1100, _t("Invalid direct date values"), "BaseModel->set()");
}
} else {
if (!$vm_value && $this->FIELDS[$vs_field]["IS_NULL"]) {
if ($vn_start_date || $vn_end_date) {