Decimal TimeInputType::defaultValueForStepUp() const { DateComponents date; date.setMillisecondsSinceMidnight(convertToLocalTime(currentTimeMS())); double milliseconds = date.millisecondsSinceEpoch(); DCHECK(std::isfinite(milliseconds)); return Decimal::fromDouble(milliseconds); }
Decimal TimeInputType::defaultValueForStepUp() const { double current = currentTimeMS(); int offset = calculateLocalTimeOffset(current).offset / msPerMinute; current += offset * msPerMinute; DateComponents date; date.setMillisecondsSinceMidnight(current); double milliseconds = date.millisecondsSinceEpoch(); ASSERT(std::isfinite(milliseconds)); return Decimal::fromDouble(milliseconds); }
Decimal TimeInputType::defaultValueForStepUp() const { double current = currentTimeMS(); double utcOffset = calculateUTCOffset(); double dstOffset = calculateDSTOffset(current, utcOffset); int offset = static_cast<int>((utcOffset + dstOffset) / msPerMinute); current += offset * msPerMinute; DateComponents date; date.setMillisecondsSinceMidnight(current); double milliseconds = date.millisecondsSinceEpoch(); ASSERT(std::isfinite(milliseconds)); return Decimal::fromDouble(milliseconds); }
static String valueToDateTimeString(double value, AtomicString type) { DateComponents components; if (type == InputTypeNames::date) components.setMillisecondsSinceEpochForDate(value); else if (type == InputTypeNames::datetime_local) components.setMillisecondsSinceEpochForDateTimeLocal(value); else if (type == InputTypeNames::month) components.setMonthsSinceEpoch(value); else if (type == InputTypeNames::time) components.setMillisecondsSinceMidnight(value); else if (type == InputTypeNames::week) components.setMillisecondsSinceEpochForWeek(value); else ASSERT_NOT_REACHED(); return components.type() == DateComponents::Invalid ? String() : components.toString(); }
DateComponents timeComponents(int hour, int minute, int second, int millisecond) { DateComponents date; date.setMillisecondsSinceMidnight(hour * msPerHour + minute * msPerMinute + second * msPerSecond + millisecond); return date; }