一、Input 类型: time
time 类型允许你选择一个时间。
html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
</head>
<body>
<form action="demo-form.php">
选择时间: <input type="time" name="usr_time">
<input type="submit">
</form>
</body>
</html>
二、time c++定义
third_party\blink\renderer\core\html\forms\time_input_type.h
third_party\blink\renderer\core\html\forms\time_input_type.cc
cpp
namespace blink {
class TimeInputType final : public BaseTemporalInputType {
public:
explicit TimeInputType(HTMLInputElement&);
private:
void CountUsage() override;
Decimal DefaultValueForStepUp() const override;
StepRange CreateStepRange(AnyStepHandling) const override;
bool ParseToDateComponentsInternal(const String&,
DateComponents*) const override;
bool SetMillisecondToDateComponents(double, DateComponents*) const override;
void WarnIfValueIsInvalid(const String&) const override;
String LocalizeValue(const String&) const override;
// BaseTemporalInputType functions
String FormatDateTimeFieldsState(const DateTimeFieldsState&) const override;
void SetupLayoutParameters(DateTimeEditElement::LayoutParameters&,
const DateComponents&) const override;
bool IsValidFormat(bool has_year,
bool has_month,
bool has_week,
bool has_day,
bool has_ampm,
bool has_hour,
bool has_minute,
bool has_second) const override;
String AriaLabelForPickerIndicator() const override;
String ReversedRangeOutOfRangeText(const Decimal& minimum,
const Decimal& maximum) const override;
};
template <>
struct DowncastTraits<TimeInputType> {
static bool AllowFrom(const InputType& type) {
return type.IsTimeInputType();
}
};
} // namespace blink