本文整理汇总了PHP中TimeExpressionParser::parseTime方法的典型用法代码示例。如果您正苦于以下问题:PHP TimeExpressionParser::parseTime方法的具体用法?PHP TimeExpressionParser::parseTime怎么用?PHP TimeExpressionParser::parseTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeExpressionParser
的用法示例。
在下文中一共展示了TimeExpressionParser::parseTime方法的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
//.........这里部分代码省略.........
$this->postError(1805, $o_tep->getParseErrorMessage(), 'BaseModel->set()', $this->tableName() . '.' . $vs_field);
return false;
}
if ($pa_fields_type == FT_HISTORIC_DATETIME || $pa_fields_type == FT_HISTORIC_DATE) {
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);
示例3: set
//.........这里部分代码省略.........
$this->postError(1805, $o_tep->getParseErrorMessage(), 'BaseModel->set()');
return false;
}
if ($pa_fields_type == FT_HISTORIC_DATETIME || $pa_fields_type == FT_HISTORIC_DATE) {
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()");