// 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 DateTimeAMPMFieldElement::setValueAsDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState) { if (dateTimeFieldsState.hasAMPM()) setValueAsInteger(dateTimeFieldsState.ampm()); else setEmptyValue(); }
void DateTimeAMPMFieldElement::setValueAsDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState, const DateComponents& dateForReadOnlyField) { if (dateTimeFieldsState.hasAMPM()) setValueAsInteger(dateTimeFieldsState.ampm()); else setEmptyValue(dateForReadOnlyField); }
String TimeInputType::formatDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState) const { if (!dateTimeFieldsState.hasHour() || !dateTimeFieldsState.hasMinute() || !dateTimeFieldsState.hasAMPM()) return emptyString(); if (dateTimeFieldsState.hasMillisecond() && dateTimeFieldsState.millisecond()) return String::format("%02u:%02u:%02u.%03u", dateTimeFieldsState.hour23(), dateTimeFieldsState.minute(), dateTimeFieldsState.hasSecond() ? dateTimeFieldsState.second() : 0, dateTimeFieldsState.millisecond()); if (dateTimeFieldsState.hasSecond() && dateTimeFieldsState.second()) return String::format("%02u:%02u:%02u", dateTimeFieldsState.hour23(), dateTimeFieldsState.minute(), dateTimeFieldsState.second()); return String::format("%02u:%02u", dateTimeFieldsState.hour23(), dateTimeFieldsState.minute()); }