void DateTimeLocalInputType::setupLayoutParameters( DateTimeEditElement::LayoutParameters& layoutParameters, const DateComponents& date) const { if (shouldHaveSecondField(date)) { layoutParameters.dateTimeFormat = layoutParameters.locale.dateTimeFormatWithSeconds(); layoutParameters.fallbackDateTimeFormat = "yyyy-MM-dd'T'HH:mm:ss"; } else { layoutParameters.dateTimeFormat = layoutParameters.locale.dateTimeFormatWithoutSeconds(); layoutParameters.fallbackDateTimeFormat = "yyyy-MM-dd'T'HH:mm"; } if (!parseToDateComponents(element().fastGetAttribute(minAttr), &layoutParameters.minimum)) layoutParameters.minimum = DateComponents(); if (!parseToDateComponents(element().fastGetAttribute(maxAttr), &layoutParameters.maximum)) layoutParameters.maximum = DateComponents(); layoutParameters.placeholderForDay = locale().queryString(WebLocalizedString::PlaceholderForDayOfMonthField); layoutParameters.placeholderForMonth = locale().queryString(WebLocalizedString::PlaceholderForMonthField); layoutParameters.placeholderForYear = locale().queryString(WebLocalizedString::PlaceholderForYearField); }
String DateTimeLocalInputType::localizeValue(const String& proposedValue) const { DateComponents date; if (!parseToDateComponents(proposedValue, &date)) return proposedValue; Locale::FormatType formatType = shouldHaveSecondField(date) ? Locale::FormatTypeMedium : Locale::FormatTypeShort; String localized = element().locale().formatDateTime(date, formatType); return localized.isEmpty() ? proposedValue : localized; }
void TimeInputType::setupLayoutParameters(DateTimeEditElement::LayoutParameters& layoutParameters, const DateComponents& date) const { if (shouldHaveSecondField(date)) { layoutParameters.dateTimeFormat = layoutParameters.locale.timeFormat(); layoutParameters.fallbackDateTimeFormat = "HH:mm:ss"; } else { layoutParameters.dateTimeFormat = layoutParameters.locale.shortTimeFormat(); layoutParameters.fallbackDateTimeFormat = "HH:mm"; } if (!parseToDateComponents(element()->fastGetAttribute(minAttr), &layoutParameters.minimum)) layoutParameters.minimum = DateComponents(); if (!parseToDateComponents(element()->fastGetAttribute(maxAttr), &layoutParameters.maximum)) layoutParameters.maximum = DateComponents(); }
void DateTimeLocalInputType::setupLayoutParameters(DateTimeEditElement::LayoutParameters& layoutParameters, const DateComponents& date) const { if (shouldHaveSecondField(date)) { layoutParameters.dateTimeFormat = layoutParameters.localizer.dateTimeFormatWithSeconds(); layoutParameters.fallbackDateTimeFormat = "dd/MM/yyyy HH:mm:ss"; } else { layoutParameters.dateTimeFormat = layoutParameters.localizer.dateTimeFormatWithoutSeconds(); layoutParameters.fallbackDateTimeFormat = "dd/MM/yyyy HH:mm"; } layoutParameters.minimumYear = fullYear(element()->fastGetAttribute(minAttr)); layoutParameters.maximumYear = fullYear(element()->fastGetAttribute(maxAttr)); layoutParameters.placeholderForDay = placeholderForDayOfMonthField(); layoutParameters.placeholderForMonth = placeholderForMonthField(); layoutParameters.placeholderForYear = placeholderForYearField(); }