// 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()); }
String DateInputType::formatDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState) const { if (!dateTimeFieldsState.hasDayOfMonth() || !dateTimeFieldsState.hasMonth() || !dateTimeFieldsState.hasYear()) return emptyString(); return String::format("%04u-%02u-%02u", dateTimeFieldsState.year(), dateTimeFieldsState.month(), dateTimeFieldsState.dayOfMonth()); }
void DateTimeSymbolicMonthFieldElement::setValueAsDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState) { if (!dateTimeFieldsState.hasMonth()) { setEmptyValue(); return; } const unsigned value = dateTimeFieldsState.month() - 1; if (value >= symbolsSize()) { setEmptyValue(); return; } setValueAsInteger(value); }
void DateTimeMonthFieldElement::setValueAsDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState) { if (!dateTimeFieldsState.hasMonth()) { setEmptyValue(); return; } const unsigned value = dateTimeFieldsState.month(); if (range().isInRange(static_cast<int>(value))) { setValueAsInteger(value); return; } setEmptyValue(); }