コード例 #1
0
TEST_F(LocaleWinTest, monthFormat)
{
    // Month format for EnglishUS:
    //  "MMMM, yyyy" on Windows 7 or older.
    //  "MMMM yyyy" on Window 8 or later.
    EXPECT_STREQ("MMMM yyyy", monthFormat(EnglishUS).replace(',', "").utf8().data());
    EXPECT_STREQ("MMMM yyyy", monthFormat(FrenchFR).utf8().data());
    EXPECT_STREQ("yyyy\xE5\xB9\xB4M\xE6\x9C\x88", monthFormat(JapaneseJP).utf8().data());
}
コード例 #2
0
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();
}