// 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 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()); }