本文整理汇总了C++中DateComponents::type方法的典型用法代码示例。如果您正苦于以下问题:C++ DateComponents::type方法的具体用法?C++ DateComponents::type怎么用?C++ DateComponents::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateComponents
的用法示例。
在下文中一共展示了DateComponents::type方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: formatDateTime
String Locale::formatDateTime(const DateComponents& date, FormatType formatType)
{
if (date.type() == DateComponents::Invalid)
return String();
DateTimeStringBuilder builder(*this, date);
switch (date.type()) {
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: 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();
}
示例3: shouldHourFieldDisabled
bool DateTimeEditBuilder::shouldHourFieldDisabled() const
{
if (m_hour23Range.isSingleton() && m_hour23Range.minimum == m_dateValue.hour()
&& !(shouldMinuteFieldDisabled() && shouldSecondFieldDisabled() && shouldMillisecondFieldDisabled()))
return true;
if (m_dateValue.type() == DateComponents::Time)
return false;
ASSERT(m_dateValue.type() == DateComponents::DateTimeLocal);
if (shouldDayOfMonthFieldDisabled()) {
ASSERT(m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear());
ASSERT(m_parameters.minimum.month() == m_parameters.maximum.month());
return false;
}
const Decimal decimalMsPerDay(static_cast<int>(msPerDay));
Decimal hourPartOfMinimum = (stepRange().stepBase().abs().remainder(decimalMsPerDay) / static_cast<int>(msPerHour)).floor();
return hourPartOfMinimum == m_dateValue.hour() && stepRange().step().remainder(decimalMsPerDay).isZero();
}
示例4: setOnlyYearMonthDay
void DateTimeEditElement::setOnlyYearMonthDay(const DateComponents& date)
{
ASSERT(date.type() == DateComponents::Date);
if (!m_editControlOwner)
return;
DateTimeFieldsState dateTimeFieldsState = valueAsDateTimeFieldsState();
dateTimeFieldsState.setYear(date.fullYear());
dateTimeFieldsState.setMonth(date.month() + 1);
dateTimeFieldsState.setDayOfMonth(date.monthDay());
setValueAsDateTimeFieldsState(dateTimeFieldsState);
m_editControlOwner->editControlValueChanged();
}
示例5: 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
ASSERT_NOT_REACHED();
return components.type() == DateComponents::Invalid ? String() : components.toString();
}
示例6: shouldDayOfMonthFieldDisabled
bool DateTimeEditBuilder::shouldDayOfMonthFieldDisabled() const
{
return m_dayRange.isSingleton() && m_dayRange.minimum == m_dateValue.monthDay() && m_dateValue.type() != DateComponents::Date;
}
示例7: visitField
void DateTimeEditBuilder::visitField(DateTimeFormat::FieldType fieldType, int count)
{
const int countForAbbreviatedMonth = 3;
const int countForFullMonth = 4;
const int countForNarrowMonth = 5;
Document& document = m_editElement.document();
switch (fieldType) {
case DateTimeFormat::FieldTypeDayOfMonth: {
RefPtrWillBeRawPtr<DateTimeFieldElement> field = DateTimeDayFieldElement::create(document, m_editElement, m_parameters.placeholderForDay, m_dayRange);
m_editElement.addField(field);
if (shouldDayOfMonthFieldDisabled()) {
field->setValueAsDate(m_dateValue);
field->setDisabled();
}
return;
}
case DateTimeFormat::FieldTypeHour11: {
DateTimeNumericFieldElement::Step step = createStep(msPerHour, msPerHour * 12);
RefPtrWillBeRawPtr<DateTimeFieldElement> field = DateTimeHour11FieldElement::create(document, m_editElement, m_hour23Range, step);
m_editElement.addField(field);
if (shouldHourFieldDisabled()) {
field->setValueAsDate(m_dateValue);
field->setDisabled();
}
return;
}
case DateTimeFormat::FieldTypeHour12: {
DateTimeNumericFieldElement::Step step = createStep(msPerHour, msPerHour * 12);
RefPtrWillBeRawPtr<DateTimeFieldElement> field = DateTimeHour12FieldElement::create(document, m_editElement, m_hour23Range, step);
m_editElement.addField(field);
if (shouldHourFieldDisabled()) {
field->setValueAsDate(m_dateValue);
field->setDisabled();
}
return;
}
case DateTimeFormat::FieldTypeHour23: {
DateTimeNumericFieldElement::Step step = createStep(msPerHour, msPerDay);
RefPtrWillBeRawPtr<DateTimeFieldElement> field = DateTimeHour23FieldElement::create(document, m_editElement, m_hour23Range, step);
m_editElement.addField(field);
if (shouldHourFieldDisabled()) {
field->setValueAsDate(m_dateValue);
field->setDisabled();
}
return;
}
case DateTimeFormat::FieldTypeHour24: {
DateTimeNumericFieldElement::Step step = createStep(msPerHour, msPerDay);
RefPtrWillBeRawPtr<DateTimeFieldElement> field = DateTimeHour24FieldElement::create(document, m_editElement, m_hour23Range, step);
m_editElement.addField(field);
if (shouldHourFieldDisabled()) {
field->setValueAsDate(m_dateValue);
field->setDisabled();
}
return;
}
case DateTimeFormat::FieldTypeMinute: {
DateTimeNumericFieldElement::Step step = createStep(msPerMinute, msPerHour);
RefPtrWillBeRawPtr<DateTimeNumericFieldElement> field = DateTimeMinuteFieldElement::create(document, m_editElement, m_minuteRange, step);
m_editElement.addField(field);
if (shouldMinuteFieldDisabled()) {
field->setValueAsDate(m_dateValue);
field->setDisabled();
}
return;
}
case DateTimeFormat::FieldTypeMonth: // Fallthrough.
case DateTimeFormat::FieldTypeMonthStandAlone: {
int minMonth = 0, maxMonth = 11;
if (m_parameters.minimum.type() != DateComponents::Invalid
&& m_parameters.maximum.type() != DateComponents::Invalid
&& m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear()
&& m_parameters.minimum.month() <= m_parameters.maximum.month()) {
minMonth = m_parameters.minimum.month();
maxMonth = m_parameters.maximum.month();
}
RefPtrWillBeRawPtr<DateTimeFieldElement> field;
switch (count) {
case countForNarrowMonth: // Fallthrough.
case countForAbbreviatedMonth:
field = DateTimeSymbolicMonthFieldElement::create(document, m_editElement, fieldType == DateTimeFormat::FieldTypeMonth ? m_parameters.locale.shortMonthLabels() : m_parameters.locale.shortStandAloneMonthLabels(), minMonth, maxMonth);
break;
case countForFullMonth:
field = DateTimeSymbolicMonthFieldElement::create(document, m_editElement, fieldType == DateTimeFormat::FieldTypeMonth ? m_parameters.locale.monthLabels() : m_parameters.locale.standAloneMonthLabels(), minMonth, maxMonth);
break;
default:
field = DateTimeMonthFieldElement::create(document, m_editElement, m_parameters.placeholderForMonth, DateTimeNumericFieldElement::Range(minMonth + 1, maxMonth + 1));
break;
}
m_editElement.addField(field);
if (minMonth == maxMonth && minMonth == m_dateValue.month() && m_dateValue.type() != DateComponents::Month) {
field->setValueAsDate(m_dateValue);
field->setDisabled();
//.........这里部分代码省略.........