• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "base/i18n/time_formatting.h"
6 
7 #include <memory>
8 
9 #include "base/i18n/rtl.h"
10 #include "base/i18n/unicodestring.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "base/test/icu_test_util.h"
13 #include "base/time/time.h"
14 #include "build/build_config.h"
15 #include "build/chromeos_buildflags.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/icu/source/common/unicode/uversion.h"
18 #include "third_party/icu/source/i18n/unicode/calendar.h"
19 #include "third_party/icu/source/i18n/unicode/timezone.h"
20 #include "third_party/icu/source/i18n/unicode/tzfmt.h"
21 
22 namespace base {
23 namespace {
24 
25 const Time::Exploded kTestDateTimeExploded = {
26     2011, 4,  6, 30,  // Sat, Apr 30, 2011
27     22,   42, 7, 0    // 22:42:07.000 in UTC = 15:42:07 in US PDT.
28 };
29 
30 // Returns difference between the local time and GMT formatted as string.
31 // This function gets |time| because the difference depends on time,
32 // see https://en.wikipedia.org/wiki/Daylight_saving_time for details.
GetShortTimeZone(const Time & time)33 std::u16string GetShortTimeZone(const Time& time) {
34   UErrorCode status = U_ZERO_ERROR;
35   std::unique_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
36   std::unique_ptr<icu::TimeZoneFormat> zone_formatter(
37       icu::TimeZoneFormat::createInstance(icu::Locale::getDefault(), status));
38   EXPECT_TRUE(U_SUCCESS(status));
39   icu::UnicodeString name;
40   zone_formatter->format(UTZFMT_STYLE_SPECIFIC_SHORT, *zone,
41                          static_cast<UDate>(time.ToDoubleT() * 1000),
42                          name, nullptr);
43   return i18n::UnicodeStringToString16(name);
44 }
45 
46 // Calls TimeDurationFormat() with |delta| and |width| and returns the resulting
47 // string. On failure, adds a failed expectation and returns an empty string.
TimeDurationFormatString(const TimeDelta & delta,DurationFormatWidth width)48 std::u16string TimeDurationFormatString(const TimeDelta& delta,
49                                         DurationFormatWidth width) {
50   std::u16string str;
51   EXPECT_TRUE(TimeDurationFormat(delta, width, &str))
52       << "Failed to format " << delta.ToInternalValue() << " with width "
53       << width;
54   return str;
55 }
56 
57 // Calls TimeDurationFormatWithSeconds() with |delta| and |width| and returns
58 // the resulting string. On failure, adds a failed expectation and returns an
59 // empty string.
TimeDurationFormatWithSecondsString(const TimeDelta & delta,DurationFormatWidth width)60 std::u16string TimeDurationFormatWithSecondsString(const TimeDelta& delta,
61                                                    DurationFormatWidth width) {
62   std::u16string str;
63   EXPECT_TRUE(TimeDurationFormatWithSeconds(delta, width, &str))
64       << "Failed to format " << delta.ToInternalValue() << " with width "
65       << width;
66   return str;
67 }
68 
TEST(TimeFormattingTest,TimeFormatTimeOfDayDefault12h)69 TEST(TimeFormattingTest, TimeFormatTimeOfDayDefault12h) {
70   // Test for a locale defaulted to 12h clock.
71   // As an instance, we use third_party/icu/source/data/locales/en.txt.
72   test::ScopedRestoreICUDefaultLocale restore_locale;
73   i18n::SetICUDefaultLocale("en_US");
74   test::ScopedRestoreDefaultTimezone la_time("America/Los_Angeles");
75 
76   Time time;
77   EXPECT_TRUE(Time::FromUTCExploded(kTestDateTimeExploded, &time));
78   std::u16string clock24h(u"15:42");
79   std::u16string clock12h_pm(u"3:42\u202fPM");
80   std::u16string clock12h(u"3:42");
81   std::u16string clock24h_millis(u"15:42:07.000");
82 
83   // The default is 12h clock.
84   EXPECT_EQ(clock12h_pm, TimeFormatTimeOfDay(time));
85   EXPECT_EQ(clock24h_millis, TimeFormatTimeOfDayWithMilliseconds(time));
86   EXPECT_EQ(k12HourClock, GetHourClockType());
87   // k{Keep,Drop}AmPm should not affect for 24h clock.
88   EXPECT_EQ(clock24h,
89             TimeFormatTimeOfDayWithHourClockType(time,
90                                                  k24HourClock,
91                                                  kKeepAmPm));
92   EXPECT_EQ(clock24h,
93             TimeFormatTimeOfDayWithHourClockType(time,
94                                                  k24HourClock,
95                                                  kDropAmPm));
96   // k{Keep,Drop}AmPm affects for 12h clock.
97   EXPECT_EQ(clock12h_pm,
98             TimeFormatTimeOfDayWithHourClockType(time,
99                                                  k12HourClock,
100                                                  kKeepAmPm));
101   EXPECT_EQ(clock12h,
102             TimeFormatTimeOfDayWithHourClockType(time,
103                                                  k12HourClock,
104                                                  kDropAmPm));
105 }
106 
TEST(TimeFormattingTest,TimeFormatTimeOfDayDefault24h)107 TEST(TimeFormattingTest, TimeFormatTimeOfDayDefault24h) {
108   // Test for a locale defaulted to 24h clock.
109   // As an instance, we use third_party/icu/source/data/locales/en_GB.txt.
110   test::ScopedRestoreICUDefaultLocale restore_locale;
111   i18n::SetICUDefaultLocale("en_GB");
112   test::ScopedRestoreDefaultTimezone la_time("America/Los_Angeles");
113 
114   Time time;
115   EXPECT_TRUE(Time::FromUTCExploded(kTestDateTimeExploded, &time));
116   std::u16string clock24h(u"15:42");
117   std::u16string clock12h_pm(u"3:42\u202fpm");
118   std::u16string clock12h(u"3:42");
119   std::u16string clock24h_millis(u"15:42:07.000");
120 
121   // The default is 24h clock.
122   EXPECT_EQ(clock24h, TimeFormatTimeOfDay(time));
123   EXPECT_EQ(clock24h_millis, TimeFormatTimeOfDayWithMilliseconds(time));
124   EXPECT_EQ(k24HourClock, GetHourClockType());
125   // k{Keep,Drop}AmPm should not affect for 24h clock.
126   EXPECT_EQ(clock24h,
127             TimeFormatTimeOfDayWithHourClockType(time,
128                                                  k24HourClock,
129                                                  kKeepAmPm));
130   EXPECT_EQ(clock24h,
131             TimeFormatTimeOfDayWithHourClockType(time,
132                                                  k24HourClock,
133                                                  kDropAmPm));
134   // k{Keep,Drop}AmPm affects for 12h clock.
135   EXPECT_EQ(clock12h_pm,
136             TimeFormatTimeOfDayWithHourClockType(time,
137                                                  k12HourClock,
138                                                  kKeepAmPm));
139   EXPECT_EQ(clock12h,
140             TimeFormatTimeOfDayWithHourClockType(time,
141                                                  k12HourClock,
142                                                  kDropAmPm));
143 }
144 
TEST(TimeFormattingTest,TimeFormatTimeOfDayJP)145 TEST(TimeFormattingTest, TimeFormatTimeOfDayJP) {
146   // Test for a locale that uses different mark than "AM" and "PM".
147   // As an instance, we use third_party/icu/source/data/locales/ja.txt.
148   test::ScopedRestoreICUDefaultLocale restore_locale;
149   i18n::SetICUDefaultLocale("ja_JP");
150   test::ScopedRestoreDefaultTimezone la_time("America/Los_Angeles");
151 
152   Time time;
153   EXPECT_TRUE(Time::FromUTCExploded(kTestDateTimeExploded, &time));
154   std::u16string clock24h(u"15:42");
155   std::u16string clock12h_pm(u"午後3:42");
156   std::u16string clock12h(u"3:42");
157 
158   // The default is 24h clock.
159   EXPECT_EQ(clock24h, TimeFormatTimeOfDay(time));
160   EXPECT_EQ(k24HourClock, GetHourClockType());
161   // k{Keep,Drop}AmPm should not affect for 24h clock.
162   EXPECT_EQ(clock24h, TimeFormatTimeOfDayWithHourClockType(time, k24HourClock,
163                                                            kKeepAmPm));
164   EXPECT_EQ(clock24h, TimeFormatTimeOfDayWithHourClockType(time, k24HourClock,
165                                                            kDropAmPm));
166   // k{Keep,Drop}AmPm affects for 12h clock.
167   EXPECT_EQ(clock12h_pm, TimeFormatTimeOfDayWithHourClockType(
168                              time, k12HourClock, kKeepAmPm));
169   EXPECT_EQ(clock12h, TimeFormatTimeOfDayWithHourClockType(time, k12HourClock,
170                                                            kDropAmPm));
171 }
172 
TEST(TimeFormattingTest,TimeFormatTimeOfDayDE)173 TEST(TimeFormattingTest, TimeFormatTimeOfDayDE) {
174   // German uses 24h by default, but uses 'AM', 'PM' for 12h format.
175   test::ScopedRestoreICUDefaultLocale restore_locale;
176   i18n::SetICUDefaultLocale("de");
177   test::ScopedRestoreDefaultTimezone la_time("America/Los_Angeles");
178 
179   Time time;
180   EXPECT_TRUE(Time::FromUTCExploded(kTestDateTimeExploded, &time));
181   std::u16string clock24h(u"15:42");
182   std::u16string clock12h_pm(u"3:42\u202fPM");
183   std::u16string clock12h(u"3:42");
184 
185   // The default is 24h clock.
186   EXPECT_EQ(clock24h, TimeFormatTimeOfDay(time));
187   EXPECT_EQ(k24HourClock, GetHourClockType());
188   // k{Keep,Drop}AmPm should not affect for 24h clock.
189   EXPECT_EQ(clock24h,
190             TimeFormatTimeOfDayWithHourClockType(time,
191                                                  k24HourClock,
192                                                  kKeepAmPm));
193   EXPECT_EQ(clock24h,
194             TimeFormatTimeOfDayWithHourClockType(time,
195                                                  k24HourClock,
196                                                  kDropAmPm));
197   // k{Keep,Drop}AmPm affects for 12h clock.
198   EXPECT_EQ(clock12h_pm,
199             TimeFormatTimeOfDayWithHourClockType(time,
200                                                  k12HourClock,
201                                                  kKeepAmPm));
202   EXPECT_EQ(clock12h,
203             TimeFormatTimeOfDayWithHourClockType(time,
204                                                  k12HourClock,
205                                                  kDropAmPm));
206 }
207 
208 #if BUILDFLAG(IS_CHROMEOS_ASH)
TEST(TimeFormattingTest,TimeMonthYearInUTC)209 TEST(TimeFormattingTest, TimeMonthYearInUTC) {
210   // See third_party/icu/source/data/locales/en.txt.
211   // The date patterns are "EEEE, MMMM d, y", "MMM d, y", and "M/d/yy".
212   test::ScopedRestoreICUDefaultLocale restore_locale;
213   i18n::SetICUDefaultLocale("en_US");
214   test::ScopedRestoreDefaultTimezone la_time("America/Los_Angeles");
215 
216   Time time;
217   EXPECT_TRUE(Time::FromUTCExploded(kTestDateTimeExploded, &time));
218   EXPECT_EQ(u"April 2011",
219             TimeFormatMonthAndYearForTimeZone(time, icu::TimeZone::getGMT()));
220   EXPECT_EQ(u"April 2011", TimeFormatMonthAndYear(time));
221 
222   const Time::Exploded kDiffMonthsForDiffTzTime = {
223       2011, 4, 5, 1,  // Fri, Apr 1, 2011 UTC = Thurs, March 31, 2011 US PDT.
224       0,    0, 0, 0   // 00:00:00.000 UTC = 05:00:00 previous day US PDT.
225   };
226 
227   EXPECT_TRUE(Time::FromUTCExploded(kDiffMonthsForDiffTzTime, &time));
228   EXPECT_EQ(u"April 2011",
229             TimeFormatMonthAndYearForTimeZone(time, icu::TimeZone::getGMT()));
230   EXPECT_EQ(u"March 2011", TimeFormatMonthAndYear(time));
231 }
232 #endif  // BUILDFLAG(IS_CHROMEOS_ASH)
233 
TEST(TimeFormattingTest,TimeFormatDateUS)234 TEST(TimeFormattingTest, TimeFormatDateUS) {
235   // See third_party/icu/source/data/locales/en.txt.
236   // The date patterns are "EEEE, MMMM d, y", "MMM d, y", and "M/d/yy".
237   test::ScopedRestoreICUDefaultLocale restore_locale;
238   i18n::SetICUDefaultLocale("en_US");
239   test::ScopedRestoreDefaultTimezone la_time("America/Los_Angeles");
240 
241   Time time;
242   EXPECT_TRUE(Time::FromUTCExploded(kTestDateTimeExploded, &time));
243 
244   EXPECT_EQ(u"Apr 30, 2011", TimeFormatShortDate(time));
245   EXPECT_EQ(u"4/30/11", TimeFormatShortDateNumeric(time));
246 
247   EXPECT_EQ(u"4/30/11, 3:42:07\u202fPM", TimeFormatShortDateAndTime(time));
248   EXPECT_EQ(u"4/30/11, 3:42:07\u202fPM " + GetShortTimeZone(time),
249             TimeFormatShortDateAndTimeWithTimeZone(time));
250 
251   EXPECT_EQ(u"April 2011", TimeFormatMonthAndYear(time));
252 
253   EXPECT_EQ(u"Saturday, April 30, 2011 at 3:42:07\u202fPM",
254             TimeFormatFriendlyDateAndTime(time));
255 
256   EXPECT_EQ(u"Saturday, April 30, 2011", TimeFormatFriendlyDate(time));
257 }
258 
TEST(TimeFormattingTest,TimeFormatDateGB)259 TEST(TimeFormattingTest, TimeFormatDateGB) {
260   // See third_party/icu/source/data/locales/en_GB.txt.
261   // The date patterns are "EEEE, d MMMM y", "d MMM y", and "dd/MM/yyyy".
262   test::ScopedRestoreICUDefaultLocale restore_locale;
263   i18n::SetICUDefaultLocale("en_GB");
264   test::ScopedRestoreDefaultTimezone la_time("America/Los_Angeles");
265 
266   Time time;
267   EXPECT_TRUE(Time::FromUTCExploded(kTestDateTimeExploded, &time));
268 
269   EXPECT_EQ(u"30 Apr 2011", TimeFormatShortDate(time));
270   EXPECT_EQ(u"30/04/2011", TimeFormatShortDateNumeric(time));
271   EXPECT_EQ(u"30/04/2011, 15:42:07", TimeFormatShortDateAndTime(time));
272   EXPECT_EQ(u"30/04/2011, 15:42:07 " + GetShortTimeZone(time),
273             TimeFormatShortDateAndTimeWithTimeZone(time));
274   EXPECT_EQ(u"April 2011", TimeFormatMonthAndYear(time));
275   EXPECT_EQ(u"Saturday, 30 April 2011 at 15:42:07",
276             TimeFormatFriendlyDateAndTime(time));
277   EXPECT_EQ(u"Saturday, 30 April 2011", TimeFormatFriendlyDate(time));
278 }
279 
TEST(TimeFormattingTest,TimeFormatWithPattern)280 TEST(TimeFormattingTest, TimeFormatWithPattern) {
281   test::ScopedRestoreICUDefaultLocale restore_locale;
282   test::ScopedRestoreDefaultTimezone la_time("America/Los_Angeles");
283 
284   Time time;
285   EXPECT_TRUE(Time::FromUTCExploded(kTestDateTimeExploded, &time));
286 
287   i18n::SetICUDefaultLocale("en_US");
288   EXPECT_EQ(u"Apr 30, 2011", TimeFormatWithPattern(time, "yMMMd"));
289   EXPECT_EQ(u"April 30 at 3:42:07\u202fPM",
290             TimeFormatWithPattern(time, "MMMMdjmmss"));
291 
292   i18n::SetICUDefaultLocale("en_GB");
293   EXPECT_EQ(u"30 Apr 2011", TimeFormatWithPattern(time, "yMMMd"));
294   EXPECT_EQ(u"30 April at 15:42:07", TimeFormatWithPattern(time, "MMMMdjmmss"));
295 
296   i18n::SetICUDefaultLocale("ja_JP");
297   EXPECT_EQ(u"2011年4月30日", TimeFormatWithPattern(time, "yMMMd"));
298   EXPECT_EQ(u"4月30日 15:42:07", TimeFormatWithPattern(time, "MMMMdjmmss"));
299 }
300 
TEST(TimeFormattingTest,TimeDurationFormat)301 TEST(TimeFormattingTest, TimeDurationFormat) {
302   test::ScopedRestoreICUDefaultLocale restore_locale;
303   TimeDelta delta = Minutes(15 * 60 + 42);
304 
305   // US English.
306   i18n::SetICUDefaultLocale("en_US");
307   EXPECT_EQ(u"15 hours, 42 minutes",
308             TimeDurationFormatString(delta, DURATION_WIDTH_WIDE));
309   EXPECT_EQ(u"15 hr, 42 min",
310             TimeDurationFormatString(delta, DURATION_WIDTH_SHORT));
311   EXPECT_EQ(u"15h 42m", TimeDurationFormatString(delta, DURATION_WIDTH_NARROW));
312   EXPECT_EQ(u"15:42", TimeDurationFormatString(delta, DURATION_WIDTH_NUMERIC));
313 
314   // Danish, with Latin alphabet but different abbreviations and punctuation.
315   i18n::SetICUDefaultLocale("da");
316   EXPECT_EQ(u"15 timer og 42 minutter",
317             TimeDurationFormatString(delta, DURATION_WIDTH_WIDE));
318   EXPECT_EQ(u"15 t. og 42 min.",
319             TimeDurationFormatString(delta, DURATION_WIDTH_SHORT));
320   EXPECT_EQ(u"15 t og 42 m",
321             TimeDurationFormatString(delta, DURATION_WIDTH_NARROW));
322   EXPECT_EQ(u"15.42", TimeDurationFormatString(delta, DURATION_WIDTH_NUMERIC));
323 
324   // Persian, with non-Arabic numbers.
325   i18n::SetICUDefaultLocale("fa");
326   std::u16string fa_wide =
327       u"\u06f1\u06f5 \u0633\u0627\u0639\u062a \u0648 \u06f4\u06f2 \u062f\u0642"
328       u"\u06cc\u0642\u0647";
329   std::u16string fa_short =
330       u"\u06f1\u06f5 \u0633\u0627\u0639\u062a\u060c\u200f \u06f4\u06f2 \u062f"
331       u"\u0642\u06cc\u0642\u0647";
332   std::u16string fa_narrow = u"\u06f1\u06f5h \u06f4\u06f2m";
333   std::u16string fa_numeric = u"\u06f1\u06f5:\u06f4\u06f2";
334   EXPECT_EQ(fa_wide, TimeDurationFormatString(delta, DURATION_WIDTH_WIDE));
335   EXPECT_EQ(fa_short, TimeDurationFormatString(delta, DURATION_WIDTH_SHORT));
336   EXPECT_EQ(fa_narrow, TimeDurationFormatString(delta, DURATION_WIDTH_NARROW));
337   EXPECT_EQ(fa_numeric,
338             TimeDurationFormatString(delta, DURATION_WIDTH_NUMERIC));
339 }
340 
TEST(TimeFormattingTest,TimeDurationFormatWithSeconds)341 TEST(TimeFormattingTest, TimeDurationFormatWithSeconds) {
342   test::ScopedRestoreICUDefaultLocale restore_locale;
343 
344   // US English.
345   i18n::SetICUDefaultLocale("en_US");
346 
347   // Test different formats.
348   TimeDelta delta = Seconds(15 * 3600 + 42 * 60 + 30);
349   EXPECT_EQ(u"15 hours, 42 minutes, 30 seconds",
350             TimeDurationFormatWithSecondsString(delta, DURATION_WIDTH_WIDE));
351   EXPECT_EQ(u"15 hr, 42 min, 30 sec",
352             TimeDurationFormatWithSecondsString(delta, DURATION_WIDTH_SHORT));
353   EXPECT_EQ(u"15h 42m 30s",
354             TimeDurationFormatWithSecondsString(delta, DURATION_WIDTH_NARROW));
355   EXPECT_EQ(u"15:42:30",
356             TimeDurationFormatWithSecondsString(delta, DURATION_WIDTH_NUMERIC));
357 
358   // Test edge case when hour >= 100.
359   delta = Seconds(125 * 3600 + 42 * 60 + 30);
360   EXPECT_EQ(u"125 hours, 42 minutes, 30 seconds",
361             TimeDurationFormatWithSecondsString(delta, DURATION_WIDTH_WIDE));
362   EXPECT_EQ(u"125 hr, 42 min, 30 sec",
363             TimeDurationFormatWithSecondsString(delta, DURATION_WIDTH_SHORT));
364   EXPECT_EQ(u"125h 42m 30s",
365             TimeDurationFormatWithSecondsString(delta, DURATION_WIDTH_NARROW));
366   EXPECT_EQ(u"125:42:30",
367             TimeDurationFormatWithSecondsString(delta, DURATION_WIDTH_NUMERIC));
368 
369   // Test edge case when minute = 0.
370   delta = Seconds(15 * 3600 + 0 * 60 + 30);
371   EXPECT_EQ(u"15 hours, 0 minutes, 30 seconds",
372             TimeDurationFormatWithSecondsString(delta, DURATION_WIDTH_WIDE));
373   EXPECT_EQ(u"15 hr, 0 min, 30 sec",
374             TimeDurationFormatWithSecondsString(delta, DURATION_WIDTH_SHORT));
375   EXPECT_EQ(u"15h 0m 30s",
376             TimeDurationFormatWithSecondsString(delta, DURATION_WIDTH_NARROW));
377   EXPECT_EQ(u"15:00:30",
378             TimeDurationFormatWithSecondsString(delta, DURATION_WIDTH_NUMERIC));
379 
380   // Test edge case when second = 0.
381   delta = Seconds(15 * 3600 + 42 * 60 + 0);
382   EXPECT_EQ(u"15 hours, 42 minutes, 0 seconds",
383             TimeDurationFormatWithSecondsString(delta, DURATION_WIDTH_WIDE));
384   EXPECT_EQ(u"15 hr, 42 min, 0 sec",
385             TimeDurationFormatWithSecondsString(delta, DURATION_WIDTH_SHORT));
386   EXPECT_EQ(u"15h 42m 0s",
387             TimeDurationFormatWithSecondsString(delta, DURATION_WIDTH_NARROW));
388   EXPECT_EQ(u"15:42:00",
389             TimeDurationFormatWithSecondsString(delta, DURATION_WIDTH_NUMERIC));
390 }
391 
TEST(TimeFormattingTest,TimeIntervalFormat)392 TEST(TimeFormattingTest, TimeIntervalFormat) {
393   test::ScopedRestoreICUDefaultLocale restore_locale;
394   i18n::SetICUDefaultLocale("en_US");
395   test::ScopedRestoreDefaultTimezone la_time("America/Los_Angeles");
396 
397   const Time::Exploded kTestIntervalEndTimeExploded = {
398       2011, 5,  6, 28,  // Sat, May 28, 2012
399       22,   42, 7, 0    // 22:42:07.000
400   };
401 
402   Time begin_time;
403   EXPECT_TRUE(Time::FromUTCExploded(kTestDateTimeExploded, &begin_time));
404   Time end_time;
405   EXPECT_TRUE(Time::FromUTCExploded(kTestIntervalEndTimeExploded, &end_time));
406 
407   EXPECT_EQ(
408       u"Saturday, April 30\u2009–\u2009Saturday, May 28",
409       DateIntervalFormat(begin_time, end_time, DATE_FORMAT_MONTH_WEEKDAY_DAY));
410 
411   const Time::Exploded kTestIntervalBeginTimeExploded = {
412       2011, 5,  1, 16,  // Mon, May 16, 2012
413       22,   42, 7, 0    // 22:42:07.000
414   };
415   EXPECT_TRUE(
416       Time::FromUTCExploded(kTestIntervalBeginTimeExploded, &begin_time));
417   EXPECT_EQ(
418       u"Monday, May 16\u2009–\u2009Saturday, May 28",
419       DateIntervalFormat(begin_time, end_time, DATE_FORMAT_MONTH_WEEKDAY_DAY));
420 
421   i18n::SetICUDefaultLocale("en_GB");
422   EXPECT_EQ(
423       u"Monday 16\u2009–\u2009Saturday 28 May",
424       DateIntervalFormat(begin_time, end_time, DATE_FORMAT_MONTH_WEEKDAY_DAY));
425 
426   i18n::SetICUDefaultLocale("ja");
427   EXPECT_EQ(
428       u"5月16日(月曜日)~28日(土曜日)",
429       DateIntervalFormat(begin_time, end_time, DATE_FORMAT_MONTH_WEEKDAY_DAY));
430 }
431 
432 }  // namespace
433 }  // namespace base
434