#include "config.h"
#if ENABLE(INPUT_TYPE_DATE)
#include "DateInputType.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "InputTypeNames.h"
namespace WebCore {
using namespace HTMLNames;
static const int dateDefaultStep = 1;
static const int dateDefaultStepBase = 0;
static const int dateStepScaleFactor = 86400000;
DateInputType::DateInputType(HTMLInputElement& element)
: BaseChooserOnlyDateAndTimeInputType(element)
{
}
const AtomicString& DateInputType::formControlType() const
{
return InputTypeNames::date();
}
DateComponents::Type DateInputType::dateType() const
{
return DateComponents::Date;
}
StepRange DateInputType::createStepRange(AnyStepHandling anyStepHandling) const
{
DEPRECATED_DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (dateDefaultStep, dateDefaultStepBase, dateStepScaleFactor, StepRange::ParsedStepValueShouldBeInteger));
const Decimal stepBase = parseToNumber(element().fastGetAttribute(minAttr), 0);
const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), Decimal::fromDouble(DateComponents::minimumDate()));
const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), Decimal::fromDouble(DateComponents::maximumDate()));
const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr));
return StepRange(stepBase, minimum, maximum, step, stepDescription);
}
bool DateInputType::parseToDateComponentsInternal(const UChar* characters, unsigned length, DateComponents* out) const
{
ASSERT(out);
unsigned end;
return out->parseDate(characters, length, 0, end) && end == length;
}
bool DateInputType::setMillisecondToDateComponents(double value, DateComponents* date) const
{
ASSERT(date);
return date->setMillisecondsSinceEpochForDate(value);
}
bool DateInputType::isDateField() const
{
return true;
}
} #endif