本文整理汇总了C++中DateTimeFieldsState::setHour方法的典型用法代码示例。如果您正苦于以下问题:C++ DateTimeFieldsState::setHour方法的具体用法?C++ DateTimeFieldsState::setHour怎么用?C++ DateTimeFieldsState::setHour使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeFieldsState
的用法示例。
在下文中一共展示了DateTimeFieldsState::setHour方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: valueAsInteger
void DateTimeHour11FieldElement::populateDateTimeFieldsState(DateTimeFieldsState& dateTimeFieldsState)
{
if (!hasValue()) {
dateTimeFieldsState.setHour(DateTimeFieldsState::emptyValue);
return;
}
const int value = valueAsInteger();
dateTimeFieldsState.setHour(value ? value : 12);
}
示例2: populateDateTimeFieldsState
void DateTimeHourFieldElement::populateDateTimeFieldsState(DateTimeFieldsState& dateTimeFieldsState)
{
if (!hasValue()) {
dateTimeFieldsState.setHour(DateTimeFieldsState::emptyValue);
return;
}
const int value = valueAsInteger();
switch (maximum()) {
case 11:
dateTimeFieldsState.setHour(value ? value : 12);
return;
case 12:
dateTimeFieldsState.setHour(value);
return;
case 23:
dateTimeFieldsState.setHour(value ? value % 12 : 12);
dateTimeFieldsState.setAMPM(value >= 12 ? DateTimeFieldsState::AMPMValuePM : DateTimeFieldsState::AMPMValueAM);
return;
case 24:
if (value == 24) {
dateTimeFieldsState.setHour(12);
dateTimeFieldsState.setHour(DateTimeFieldsState::AMPMValueAM);
return;
}
dateTimeFieldsState.setHour(value == 12 ? 12 : value % 12);
dateTimeFieldsState.setAMPM(value >= 12 ? DateTimeFieldsState::AMPMValuePM : DateTimeFieldsState::AMPMValueAM);
return;
default:
ASSERT_NOT_REACHED();
}
}
示例3: restoreFormControlState
DateTimeFieldsState DateTimeFieldsState::restoreFormControlState(const FormControlState& state)
{
DateTimeFieldsState dateTimeFieldsState;
dateTimeFieldsState.setYear(getNumberFromFormControlState(state, 0));
dateTimeFieldsState.setMonth(getNumberFromFormControlState(state, 1));
dateTimeFieldsState.setDayOfMonth(getNumberFromFormControlState(state, 2));
dateTimeFieldsState.setHour(getNumberFromFormControlState(state, 3));
dateTimeFieldsState.setMinute(getNumberFromFormControlState(state, 4));
dateTimeFieldsState.setSecond(getNumberFromFormControlState(state, 5));
dateTimeFieldsState.setMillisecond(getNumberFromFormControlState(state, 6));
dateTimeFieldsState.setWeekOfYear(getNumberFromFormControlState(state, 7));
dateTimeFieldsState.setAMPM(getAMPMFromFormControlState(state, 8));
return dateTimeFieldsState;
}