Example #1
0
String WeekInputType::formatDateTimeFieldsState(
    const DateTimeFieldsState& dateTimeFieldsState) const {
  if (!dateTimeFieldsState.hasYear() || !dateTimeFieldsState.hasWeekOfYear())
    return emptyString();
  return String::format("%04u-W%02u", dateTimeFieldsState.year(),
                        dateTimeFieldsState.weekOfYear());
}
void DateTimeWeekFieldElement::setValueAsDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState)
{
    if (!dateTimeFieldsState.hasWeekOfYear()) {
        setEmptyValue();
        return;
    }

    const unsigned value = dateTimeFieldsState.weekOfYear();
    if (range().isInRange(static_cast<int>(value))) {
        setValueAsInteger(value);
        return;
    }

    setEmptyValue();
}