#include "base/i18n/time_formatting.h"
#include <memory>
#include "base/i18n/rtl.h"
#include "base/i18n/unicodestring.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/icu_test_util.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/icu/source/common/unicode/uversion.h"
#include "third_party/icu/source/i18n/unicode/calendar.h"
#include "third_party/icu/source/i18n/unicode/timezone.h"
#include "third_party/icu/source/i18n/unicode/tzfmt.h"
namespace base {
namespace {
constexpr Time::Exploded kTestDateTimeExploded = …;
std::u16string GetShortTimeZone(const Time& time) { … }
std::u16string TimeDurationFormatString(const TimeDelta& delta,
DurationFormatWidth width) { … }
std::u16string TimeDurationFormatWithSecondsString(const TimeDelta& delta,
DurationFormatWidth width) { … }
std::u16string TimeDurationCompactFormatWithSecondsString(
const TimeDelta& delta,
DurationFormatWidth width) { … }
TEST(TimeFormattingTest, TimeFormatTimeOfDayDefault12h) { … }
TEST(TimeFormattingTest, TimeFormatTimeOfDayDefault24h) { … }
TEST(TimeFormattingTest, TimeFormatTimeOfDayJP) { … }
TEST(TimeFormattingTest, TimeFormatTimeOfDayDE) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST(TimeFormattingTest, TimeMonthYearInUTC) {
test::ScopedRestoreICUDefaultLocale restore_locale;
i18n::SetICUDefaultLocale("en_US");
test::ScopedRestoreDefaultTimezone la_time("America/Los_Angeles");
Time time;
EXPECT_TRUE(Time::FromUTCExploded(kTestDateTimeExploded, &time));
EXPECT_EQ(u"April 2011",
TimeFormatMonthAndYearForTimeZone(time, icu::TimeZone::getGMT()));
EXPECT_EQ(u"April 2011", TimeFormatMonthAndYear(time));
const Time::Exploded kDiffMonthsForDiffTzTime = {
2011, 4, 5, 1,
0, 0, 0, 0
};
EXPECT_TRUE(Time::FromUTCExploded(kDiffMonthsForDiffTzTime, &time));
EXPECT_EQ(u"April 2011",
TimeFormatMonthAndYearForTimeZone(time, icu::TimeZone::getGMT()));
EXPECT_EQ(u"March 2011", TimeFormatMonthAndYear(time));
}
#endif
TEST(TimeFormattingTest, TimeFormatDateUS) { … }
TEST(TimeFormattingTest, TimeFormatDateGB) { … }
TEST(TimeFormattingTest, TimeFormatWithPattern) { … }
TEST(TimeFormattingTest, UnlocalizedTimeFormatWithPatternMicroseconds) { … }
TEST(TimeFormattingTest, TimeFormatAsIso8601) { … }
TEST(TimeFormattingTest, TimeFormatHTTP) { … }
TEST(TimeFormattingTest, TimeDurationFormat) { … }
TEST(TimeFormattingTest, TimeDurationFormatWithSeconds) { … }
TEST(TimeFormattingTest, TimeDurationCompactFormatWithSeconds) { … }
TEST(TimeFormattingTest, TimeIntervalFormat) { … }
}
}