void DateTimeHour11FieldElement::populateDateTimeFieldsState(DateTimeFieldsState& dateTimeFieldsState) { if (!hasValue()) { dateTimeFieldsState.setHour(DateTimeFieldsState::emptyValue); return; } const int value = valueAsInteger(); dateTimeFieldsState.setHour(value ? value : 12); }
void DateTimeHour23FieldElement::populateDateTimeFieldsState(DateTimeFieldsState& dateTimeFieldsState) { if (!hasValue()) { dateTimeFieldsState.setHour(DateTimeFieldsState::emptyValue); return; } const int value = valueAsInteger(); dateTimeFieldsState.setHour(value % 12 ? value % 12 : 12); dateTimeFieldsState.setAMPM(value >= 12 ? DateTimeFieldsState::AMPMValuePM : DateTimeFieldsState::AMPMValueAM); }
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(); } }
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; }
void DateTimeHour12FieldElement::populateDateTimeFieldsState(DateTimeFieldsState& dateTimeFieldsState) { dateTimeFieldsState.setHour(hasValue() ? valueAsInteger() : DateTimeFieldsState::emptyValue); }