本文整理汇总了C++中DateComponents类的典型用法代码示例。如果您正苦于以下问题:C++ DateComponents类的具体用法?C++ DateComponents怎么用?C++ DateComponents使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DateComponents类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defaultValueForStepUp
Decimal TimeInputType::defaultValueForStepUp() const {
DateComponents date;
date.setMillisecondsSinceMidnight(convertToLocalTime(currentTimeMS()));
double milliseconds = date.millisecondsSinceEpoch();
DCHECK(std::isfinite(milliseconds));
return Decimal::fromDouble(milliseconds);
}
示例2: fullYear
int BaseMultipleFieldsDateAndTimeInputType::fullYear(const String& source) const
{
DateComponents date;
if (!parseToDateComponents(source, &date))
return DateTimeEditElement::LayoutParameters::undefinedYear();
return date.fullYear();
}
示例3: String
String Locale::formatDateTime(const DateComponents& date, FormatType formatType)
{
if (date.getType() == DateComponents::Invalid)
return String();
DateTimeStringBuilder builder(*this, date);
switch (date.getType()) {
case DateComponents::Time:
builder.build(formatType == FormatTypeShort ? shortTimeFormat() : timeFormat());
break;
case DateComponents::Date:
builder.build(dateFormat());
break;
case DateComponents::Month:
builder.build(formatType == FormatTypeShort ? shortMonthFormat() : monthFormat());
break;
case DateComponents::Week:
builder.build(weekFormatInLDML());
break;
case DateComponents::DateTime:
case DateComponents::DateTimeLocal:
builder.build(formatType == FormatTypeShort ? dateTimeFormatWithoutSeconds() : dateTimeFormatWithSeconds());
break;
case DateComponents::Invalid:
ASSERT_NOT_REACHED();
break;
}
return builder.toString();
}
示例4: sanitizeValue
String DateTimeInputType::sanitizeValue(const String& proposedValue) const
{
DateComponents date;
if (!parseToDateComponents(proposedValue, &date))
return String();
return date.toString();
}
示例5: emptyString
String PagePopupController::formatShortMonth(int year, int zeroBaseMonth) {
if (!m_popupClient)
return emptyString();
DateComponents date;
date.setMonthsSinceEpoch((year - 1970) * 12.0 + zeroBaseMonth);
return m_popupClient->locale().formatDateTime(date, Locale::FormatTypeShort);
}
示例6: serializeWithMilliseconds
String MonthInputType::serializeWithMilliseconds(double value) const
{
DateComponents date;
if (!date.setMillisecondsSinceEpochForMonth(value))
return String();
return serializeWithComponents(date);
}
示例7: shouldHaveSecondField
bool BaseMultipleFieldsDateAndTimeInputType::shouldHaveSecondField(const DateComponents& date) const
{
StepRange stepRange = createStepRange(AnyIsDefaultStep);
return date.second() || date.millisecond()
|| !stepRange.minimum().remainder(static_cast<int>(msPerMinute)).isZero()
|| !stepRange.step().remainder(static_cast<int>(msPerMinute)).isZero();
}
示例8: formatLocalizedDate
String formatLocalizedDate(const DateComponents& dateComponents)
{
switch (dateComponents.type()) {
case DateComponents::Date: {
UDateFormat* dateFormat = createShortDateFormatter();
if (!dateFormat)
break;
double input = dateComponents.millisecondsSinceEpoch();
UErrorCode status = U_ZERO_ERROR;
int32_t length = udat_format(dateFormat, input, 0, 0, 0, &status);
if (status != U_BUFFER_OVERFLOW_ERROR) {
udat_close(dateFormat);
break;
}
Vector<UChar> buffer(length);
status = U_ZERO_ERROR;
udat_format(dateFormat, input, buffer.data(), length, 0, &status);
udat_close(dateFormat);
if (U_FAILURE(status))
break;
return String::adopt(buffer);
}
case DateComponents::DateTime:
case DateComponents::DateTimeLocal:
case DateComponents::Month:
case DateComponents::Time:
case DateComponents::Week:
case DateComponents::Invalid:
break;
}
return String();
}
示例9: formatMonth
String formatMonth(const String& localeString, const String& isoString, bool useShortFormat)
{
OwnPtr<LocaleMac> locale = LocaleMac::create(localeString);
DateComponents date;
unsigned end;
date.parseMonth(isoString.characters(), isoString.length(), 0, end);
return locale->formatDateTime(date, (useShortFormat ? Locale::FormatTypeShort : Locale::FormatTypeMedium));
}
示例10: formatWeek
String formatWeek(const String& localeString, const String& isoString)
{
OwnPtr<LocaleMac> locale = LocaleMac::create(localeString);
DateComponents date;
unsigned end;
date.parseWeek(isoString.characters(), isoString.length(), 0, end);
return locale->formatDateTime(date);
}
示例11: parseToDouble
double MonthInputType::parseToDouble(const String& src, double defaultValue) const
{
DateComponents date;
if (!parseToDateComponents(src, &date))
return defaultValue;
double months = date.monthsSinceEpoch();
ASSERT(isfinite(months));
return months;
}
示例12: parseToDouble
double BaseDateAndTimeInputType::parseToDouble(const String& src, double defaultValue) const
{
DateComponents date;
if (!parseToDateComponents(src, &date))
return defaultValue;
double msec = date.millisecondsSinceEpoch();
ASSERT(isfinite(msec));
return msec;
}
示例13: parseToNumber
Decimal BaseDateAndTimeInputType::parseToNumber(const String& source, const Decimal& defaultValue) const
{
DateComponents date;
if (!parseToDateComponents(source, &date))
return defaultValue;
double msec = date.millisecondsSinceEpoch();
ASSERT(isfinite(msec));
return Decimal::fromDouble(msec);
}
示例14: valueAsDate
double MonthInputType::valueAsDate() const
{
DateComponents date;
if (!parseToDateComponents(element().value(), &date))
return DateComponents::invalidMilliseconds();
double msec = date.millisecondsSinceEpoch();
ASSERT(std::isfinite(msec));
return msec;
}
示例15: parseToNumber
Decimal MonthInputType::parseToNumber(const String& src, const Decimal& defaultValue) const
{
DateComponents date;
if (!parseToDateComponents(src, &date))
return defaultValue;
double months = date.monthsSinceEpoch();
ASSERT(std::isfinite(months));
return Decimal::fromDouble(months);
}