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

Unified Diff: base/i18n/time_formatting.h

Issue 2736363002: 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
« no previous file with comments | « ash/common/system/chromeos/power/power_status_view.cc ('k') | base/i18n/time_formatting.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/i18n/time_formatting.h
diff --git a/base/i18n/time_formatting.h b/base/i18n/time_formatting.h
index ba09b44f3a60613215afa60a5114c29d3f13b30c..41793b339ceb02879f49f7235433b8db7a09f964 100644
--- a/base/i18n/time_formatting.h
+++ b/base/i18n/time_formatting.h
@@ -8,6 +8,7 @@
#ifndef BASE_I18N_TIME_FORMATTING_H_
#define BASE_I18N_TIME_FORMATTING_H_
+#include "base/compiler_specific.h"
#include "base/i18n/base_i18n_export.h"
#include "base/strings/string16.h"
@@ -46,6 +47,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 +100,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,
+ const DurationFormatWidth width,
+ string16* out) WARN_UNUSED_RESULT;
// 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) WARN_UNUSED_RESULT;
// Formats a date interval into various formats, e.g. "2 December - 4 December"
// or "March 2016 - December 2016". See DateFormat for details.
« no previous file with comments | « ash/common/system/chromeos/power/power_status_view.cc ('k') | base/i18n/time_formatting.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698