#include "base/i18n/time_formatting.h"
#include <stddef.h>
#include <memory>
#include <string>
#include <string_view>
#include "base/i18n/unicodestring.h"
#include "base/logging.h"
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "build/chromeos_buildflags.h"
#include "third_party/icu/source/common/unicode/locid.h"
#include "third_party/icu/source/common/unicode/utypes.h"
#include "third_party/icu/source/i18n/unicode/datefmt.h"
#include "third_party/icu/source/i18n/unicode/dtitvfmt.h"
#include "third_party/icu/source/i18n/unicode/dtptngen.h"
#include "third_party/icu/source/i18n/unicode/fmtable.h"
#include "third_party/icu/source/i18n/unicode/measfmt.h"
#include "third_party/icu/source/i18n/unicode/smpdtfmt.h"
#include "third_party/icu/source/i18n/unicode/timezone.h"
namespace base {
namespace {
UDate ToUDate(const Time& time) { … }
std::u16string TimeFormat(const icu::DateFormat& formatter, const Time& time) { … }
std::u16string TimeFormatWithoutAmPm(const icu::DateFormat* formatter,
const Time& time) { … }
icu::SimpleDateFormat CreateSimpleDateFormatter(
std::string_view pattern,
bool generate_pattern = true,
const icu::Locale& locale = icu::Locale::getDefault()) { … }
UMeasureFormatWidth DurationWidthToMeasureWidth(DurationFormatWidth width) { … }
const char* DateFormatToString(DateFormat format) { … }
}
std::u16string TimeFormatTimeOfDay(const Time& time) { … }
std::u16string TimeFormatTimeOfDayWithMilliseconds(const Time& time) { … }
std::u16string TimeFormatTimeOfDayWithHourClockType(const Time& time,
HourClockType type,
AmPmClockType ampm) { … }
std::u16string TimeFormatShortDate(const Time& time) { … }
std::u16string TimeFormatShortDateNumeric(const Time& time) { … }
std::u16string TimeFormatShortDateAndTime(const Time& time) { … }
std::u16string TimeFormatShortDateAndTimeWithTimeZone(const Time& time) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
std::u16string TimeFormatMonthAndYearForTimeZone(
const Time& time,
const icu::TimeZone* time_zone) {
icu::SimpleDateFormat formatter =
CreateSimpleDateFormatter(DateFormatToString(DATE_FORMAT_YEAR_MONTH));
formatter.setTimeZone(*time_zone);
return TimeFormat(formatter, time);
}
#endif
std::u16string TimeFormatMonthAndYear(const Time& time) { … }
std::u16string TimeFormatFriendlyDateAndTime(const Time& time) { … }
std::u16string TimeFormatFriendlyDate(const Time& time) { … }
std::u16string LocalizedTimeFormatWithPattern(const Time& time,
std::string_view pattern) { … }
std::string UnlocalizedTimeFormatWithPattern(const Time& time,
std::string_view pattern,
const icu::TimeZone* time_zone) { … }
std::string TimeFormatAsIso8601(const Time& time) { … }
std::string TimeFormatHTTP(const Time& time) { … }
bool TimeDurationFormat(TimeDelta time,
DurationFormatWidth width,
std::u16string* out) { … }
bool TimeDurationFormatWithSeconds(TimeDelta time,
DurationFormatWidth width,
std::u16string* out) { … }
bool TimeDurationCompactFormatWithSeconds(TimeDelta time,
DurationFormatWidth width,
std::u16string* out) { … }
std::u16string DateIntervalFormat(const Time& begin_time,
const Time& end_time,
DateFormat format) { … }
HourClockType GetHourClockType() { … }
}