コード例 #1
0
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);
}
コード例 #2
0
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;
}
コード例 #3
0
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();
}
コード例 #4
0
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();
}