本文整理汇总了C++中DateTimeFieldsState类的典型用法代码示例。如果您正苦于以下问题:C++ DateTimeFieldsState类的具体用法?C++ DateTimeFieldsState怎么用?C++ DateTimeFieldsState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DateTimeFieldsState类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void DateTimeHourFieldElement::populateDateTimeFieldsState(DateTimeFieldsState& dateTimeFieldsState)
{
if (!hasValue()) {
dateTimeFieldsState.setHour(DateTimeFieldsState::emptyValue);
return;
}
const int value = DateTimeNumericFieldElement::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();
}
}
示例2: valueAsInteger
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);
}
示例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;
}
示例4: ASSERT
void DateTimeEditElement::setOnlyYearMonthDay(const DateComponents& date)
{
ASSERT(date.type() == DateComponents::Date);
if (!m_editControlOwner)
return;
DateTimeFieldsState dateTimeFieldsState = valueAsDateTimeFieldsState();
dateTimeFieldsState.setYear(date.fullYear());
dateTimeFieldsState.setMonth(date.month() + 1);
dateTimeFieldsState.setDayOfMonth(date.monthDay());
setValueAsDateTimeFieldsState(dateTimeFieldsState);
m_editControlOwner->editControlValueChanged();
}
示例5: setValueAsDateTimeFieldsState
void DateTimeSymbolicMonthFieldElement::setValueAsDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState)
{
if (!dateTimeFieldsState.hasMonth()) {
setEmptyValue();
return;
}
const unsigned value = dateTimeFieldsState.month() - 1;
if (value >= symbolsSize()) {
setEmptyValue();
return;
}
setValueAsInteger(value);
}
示例6: setValueAsDateTimeFieldsState
void DateTimeYearFieldElement::setValueAsDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState, const DateComponents& dateForReadOnlyField)
{
if (!dateTimeFieldsState.hasYear()) {
setEmptyValue(dateForReadOnlyField);
return;
}
const unsigned value = dateTimeFieldsState.year();
if (range().isInRange(static_cast<int>(value))) {
setValueAsInteger(value);
return;
}
setEmptyValue(dateForReadOnlyField);
}
示例7: setEmptyValue
void DateTimeHourFieldElementBase::setValueAsDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState)
{
if (!dateTimeFieldsState.hasHour()) {
setEmptyValue();
return;
}
const int hour12 = dateTimeFieldsState.hour();
if (hour12 < 1 || hour12 > 12) {
setEmptyValue();
return;
}
const int hour11 = hour12 == 12 ? 0 : hour12;
const int hour23 = dateTimeFieldsState.ampm() == DateTimeFieldsState::AMPMValuePM ? hour11 + 12 : hour11;
setValueAsInteger(hour23);
}
示例8: setEmptyValue
void DateTimeHourFieldElement::setValueAsDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState)
{
if (!dateTimeFieldsState.hasHour()) {
setEmptyValue();
return;
}
const int hour12 = dateTimeFieldsState.hour();
if (hour12 < 1 || hour12 > 12) {
setEmptyValue();
return;
}
switch (maximum()) {
case 11:
DateTimeNumericFieldElement::setValueAsInteger(hour12 % 12);
return;
case 12:
DateTimeNumericFieldElement::setValueAsInteger(hour12);
return;
case 23:
if (dateTimeFieldsState.ampm() == DateTimeFieldsState::AMPMValuePM)
DateTimeNumericFieldElement::setValueAsInteger((hour12 + 12) % 24);
else
DateTimeNumericFieldElement::setValueAsInteger(hour12 % 12);
return;
case 24:
if (dateTimeFieldsState.ampm() == DateTimeFieldsState::AMPMValuePM)
DateTimeNumericFieldElement::setValueAsInteger(hour12 == 12 ? 12 : hour12 + 12);
else
DateTimeNumericFieldElement::setValueAsInteger(hour12);
return;
default:
ASSERT_NOT_REACHED();
}
}
示例9: formatDateTimeFieldsState
String MonthInputType::formatDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState) const
{
if (!dateTimeFieldsState.hasMonth() || !dateTimeFieldsState.hasYear())
return emptyString();
return String::format("%04u-%02u", dateTimeFieldsState.year(), dateTimeFieldsState.month());
}
示例10: formatDateTimeFieldsState
// FIXME: It is better to share code for DateTimeInputType::formatDateTimeFieldsState()
// and DateTimeInputLocalType::formatDateTimeFieldsState().
String DateTimeInputType::formatDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState) const
{
if (!dateTimeFieldsState.hasDayOfMonth() || !dateTimeFieldsState.hasMonth() || !dateTimeFieldsState.hasYear()
|| !dateTimeFieldsState.hasHour() || !dateTimeFieldsState.hasMinute() || !dateTimeFieldsState.hasAMPM())
return emptyString();
if (dateTimeFieldsState.hasMillisecond() && dateTimeFieldsState.millisecond()) {
return String::format("%04u-%02u-%02uT%02u:%02u:%02u.%03uZ",
dateTimeFieldsState.year(),
dateTimeFieldsState.month(),
dateTimeFieldsState.dayOfMonth(),
dateTimeFieldsState.hour23(),
dateTimeFieldsState.minute(),
dateTimeFieldsState.hasSecond() ? dateTimeFieldsState.second() : 0,
dateTimeFieldsState.millisecond());
}
if (dateTimeFieldsState.hasSecond() && dateTimeFieldsState.second()) {
return String::format("%04u-%02u-%02uT%02u:%02u:%02uZ",
dateTimeFieldsState.year(),
dateTimeFieldsState.month(),
dateTimeFieldsState.dayOfMonth(),
dateTimeFieldsState.hour23(),
dateTimeFieldsState.minute(),
dateTimeFieldsState.second());
}
return String::format("%04u-%02u-%02uT%02u:%02uZ",
dateTimeFieldsState.year(),
dateTimeFieldsState.month(),
dateTimeFieldsState.dayOfMonth(),
dateTimeFieldsState.hour23(),
dateTimeFieldsState.minute());
}
示例11: valueAsInteger
void DateTimeDayFieldElement::populateDateTimeFieldsState(DateTimeFieldsState& dateTimeFieldsState)
{
dateTimeFieldsState.setDayOfMonth(hasValue() ? valueAsInteger() : DateTimeFieldsState::emptyValue);
}