Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(560)

Unified Diff: base/i18n/time_formatting.h

Issue 2734883003: base: Make TimeDurationFormat* report failures. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/i18n/time_formatting.h
diff --git a/base/i18n/time_formatting.h b/base/i18n/time_formatting.h
index ba09b44f3a60613215afa60a5114c29d3f13b30c..9edfa7edfb3eb96db55f0833148558bec97691e4 100644
--- a/base/i18n/time_formatting.h
+++ b/base/i18n/time_formatting.h
@@ -46,6 +46,10 @@ enum DateFormat {
DATE_FORMAT_MONTH_WEEKDAY_DAY,
};
+// TODO(derat@chromium.org): Update all of these functions to return boolean
+// "success" values and use out-params for formatted strings:
+// http://crbug.com/698802
+
// Returns the time of day, e.g., "3:07 PM".
BASE_I18N_EXPORT string16 TimeFormatTimeOfDay(const Time& time);
@@ -95,28 +99,31 @@ BASE_I18N_EXPORT string16 TimeFormatWithPattern(const Time& time,
const char* pattern);
// Formats a time duration of hours and minutes into various formats, e.g.,
-// "3:07" or "3 hours, 7 minutes". See DurationFormatWidth for details.
+// "3:07" or "3 hours, 7 minutes", and returns true on success. See
+// DurationFormatWidth for details.
//
// Please don't use width = DURATION_WIDTH_NUMERIC when the time duration
// can possibly be larger than 24h, as the hour value will be cut below 24
// after formatting.
// TODO(chengx): fix function output when width = DURATION_WIDTH_NUMERIC
// (http://crbug.com/675791)
-BASE_I18N_EXPORT string16 TimeDurationFormat(const TimeDelta time,
- const DurationFormatWidth width);
+BASE_I18N_EXPORT bool TimeDurationFormat(const TimeDelta time,
bruthig 2017/03/06 21:12:38 Consider using the WARN_UNUSED_RESULT macro here.
Daniel Erat 2017/03/06 21:24:32 sure, sounds good.
+ const DurationFormatWidth width,
+ string16* out);
// Formats a time duration of hours, minutes and seconds into various formats,
-// e.g., "3:07:30" or "3 hours, 7 minutes, 30 seconds". See DurationFormatWidth
-// for details.
+// e.g., "3:07:30" or "3 hours, 7 minutes, 30 seconds", and returns true on
+// success. See DurationFormatWidth for details.
//
// Please don't use width = DURATION_WIDTH_NUMERIC when the time duration
// can possibly be larger than 24h, as the hour value will be cut below 24
// after formatting.
// TODO(chengx): fix function output when width = DURATION_WIDTH_NUMERIC
// (http://crbug.com/675791)
-BASE_I18N_EXPORT string16
-TimeDurationFormatWithSeconds(const TimeDelta time,
- const DurationFormatWidth width);
+BASE_I18N_EXPORT bool TimeDurationFormatWithSeconds(
+ const TimeDelta time,
+ const DurationFormatWidth width,
+ string16* out);
// Formats a date interval into various formats, e.g. "2 December - 4 December"
// or "March 2016 - December 2016". See DateFormat for details.

Powered by Google App Engine
This is Rietveld 408576698