本文整理汇总了C++中DateComponents::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ DateComponents::getType方法的具体用法?C++ DateComponents::getType怎么用?C++ DateComponents::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateComponents
的用法示例。
在下文中一共展示了DateComponents::getType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: formatDateTime
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();
}
示例2: valueToDateTimeString
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
NOTREACHED();
return components.getType() == DateComponents::Invalid ? String() : components.toString();
}