chromium/base/i18n/time_formatting_unittest.cc

// Copyright 2011 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 =;

// Returns difference between the local time and GMT formatted as string.
// This function gets |time| because the difference depends on time,
// see https://en.wikipedia.org/wiki/Daylight_saving_time for details.
std::u16string GetShortTimeZone(const Time& time) {}

// Calls TimeDurationFormat() with |delta| and |width| and returns the resulting
// string. On failure, adds a failed expectation and returns an empty string.
std::u16string TimeDurationFormatString(const TimeDelta& delta,
                                        DurationFormatWidth width) {}

// Calls TimeDurationFormatWithSeconds() with |delta| and |width| and returns
// the resulting string. On failure, adds a failed expectation and returns an
// empty string.
std::u16string TimeDurationFormatWithSecondsString(const TimeDelta& delta,
                                                   DurationFormatWidth width) {}

// Calls TimeDurationCompactFormatWithSeconds() with |delta| and |width| and
// returns the resulting string. On failure, adds a failed expectation and
// returns an empty string.
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) {
  // See third_party/icu/source/data/locales/en.txt.
  // The date patterns are "EEEE, MMMM d, y", "MMM d, y", and "M/d/yy".
  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,  // Fri, Apr 1, 2011 UTC = Thurs, March 31, 2011 US PDT.
      0,    0, 0, 0   // 00:00:00.000 UTC = 05:00:00 previous day US PDT.
  };

  EXPECT_TRUE(Time::FromUTCExploded(kDiffMonthsForDiffTzTime, &time));
  EXPECT_EQ(u"April 2011",
            TimeFormatMonthAndYearForTimeZone(time, icu::TimeZone::getGMT()));
  EXPECT_EQ(u"March 2011", TimeFormatMonthAndYear(time));
}
#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

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) {}

}  // namespace
}  // namespace base