// 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()); }
void DateTimeDayFieldElement::setValueAsDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState) { if (!dateTimeFieldsState.hasDayOfMonth()) { setEmptyValue(); return; } const unsigned value = dateTimeFieldsState.dayOfMonth(); if (range().isInRange(static_cast<int>(value))) { setValueAsInteger(value); return; } setEmptyValue(); }
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()); }