当前位置: 首页>>代码示例>>C++>>正文


C++ DateComponents类代码示例

本文整理汇总了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);
}
开发者ID:mirror,项目名称:chromium,代码行数:7,代码来源:TimeInputType.cpp

示例2: fullYear

int BaseMultipleFieldsDateAndTimeInputType::fullYear(const String& source) const
{
    DateComponents date;
    if (!parseToDateComponents(source, &date))
        return DateTimeEditElement::LayoutParameters::undefinedYear();
    return date.fullYear();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例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();
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例4: sanitizeValue

String DateTimeInputType::sanitizeValue(const String& proposedValue) const
{
    DateComponents date;
    if (!parseToDateComponents(proposedValue, &date))
        return String();
    return date.toString();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例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);
}
开发者ID:mirror,项目名称:chromium,代码行数:7,代码来源:PagePopupController.cpp

示例6: serializeWithMilliseconds

String MonthInputType::serializeWithMilliseconds(double value) const
{
    DateComponents date;
    if (!date.setMillisecondsSinceEpochForMonth(value))
        return String();
    return serializeWithComponents(date);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:7,代码来源:MonthInputType.cpp

示例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();
}
开发者ID:kjthegod,项目名称:WebKit,代码行数:7,代码来源:BaseMultipleFieldsDateAndTimeInputType.cpp

示例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();
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例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));
 }
开发者ID:Channely,项目名称:know-your-chrome,代码行数:8,代码来源:LocaleMacTest.cpp

示例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);
 }
开发者ID:Channely,项目名称:know-your-chrome,代码行数:8,代码来源:LocaleMacTest.cpp

示例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;
}
开发者ID:Xertz,项目名称:EAWebKit,代码行数:9,代码来源:MonthInputType.cpp

示例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;
}
开发者ID:Moondee,项目名称:Artemis,代码行数:9,代码来源:BaseDateAndTimeInputType.cpp

示例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);
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例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;
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:9,代码来源:MonthInputType.cpp

示例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);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:9,代码来源:MonthInputType.cpp


注:本文中的DateComponents类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。