#include "config.h"
#if ENABLE(INPUT_TYPE_WEEK)
#include "WeekInputType.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "InputTypeNames.h"
namespace WebCore {
using namespace HTMLNames;
static const int weekDefaultStepBase = -259200000; static const int weekDefaultStep = 1;
static const int weekStepScaleFactor = 604800000;
const AtomicString& WeekInputType::formControlType() const
{
return InputTypeNames::week();
}
DateComponents::Type WeekInputType::dateType() const
{
return DateComponents::Week;
}
StepRange WeekInputType::createStepRange(AnyStepHandling anyStepHandling) const
{
DEPRECATED_DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (weekDefaultStep, weekDefaultStepBase, weekStepScaleFactor, StepRange::ParsedStepValueShouldBeInteger));
const Decimal stepBase = parseToNumber(element().fastGetAttribute(minAttr), weekDefaultStepBase);
const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), Decimal::fromDouble(DateComponents::minimumWeek()));
const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), Decimal::fromDouble(DateComponents::maximumWeek()));
const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr));
return StepRange(stepBase, minimum, maximum, step, stepDescription);
}
bool WeekInputType::parseToDateComponentsInternal(const UChar* characters, unsigned length, DateComponents* out) const
{
ASSERT(out);
unsigned end;
return out->parseWeek(characters, length, 0, end) && end == length;
}
bool WeekInputType::setMillisecondToDateComponents(double value, DateComponents* date) const
{
ASSERT(date);
return date->setMillisecondsSinceEpochForWeek(value);
}
bool WeekInputType::isWeekField() const
{
return true;
}
}
#endif