Fix style formatting issue in BTimeUnitFormat, update BDurationFormat accordingly.

* Issue: BTimeUnitFormat doesn't incorporate style formatting while
formatting a time unit. Format() does take style as an argument but the
style is not used anywhere. So currently the abbreviated style doesn't
work and by default the time unit is formatted to the full style.

* Fix: Move the style flag from BTimeUnitFormat::Format() to the
BTimeUnitFormat constructors and call the relevant icu::TimeUnitFormat
constructor. Map the Haiku defined style unit to the corresponding ICU
unit. Move the style flag from BDurationFormat::Format() to the
BDurationFormat constructors to map the changes in BTimeUnitFormat.

Signed-off-by: Adrien Destugues <[email protected]>

Fixes #13508
This commit is contained in:
Akshay Agarwal
2017-05-17 19:53:46 +02:00
committed by Adrien Destugues
parent f286626cd0
commit f5c544b59a
4 changed files with 45 additions and 22 deletions
+5 -5
View File
@@ -28,9 +28,10 @@ class BDurationFormat : public BFormat {
public:
BDurationFormat(const BLanguage& language,
const BFormattingConventions& conventions,
const BString& separator = ", ");
BDurationFormat(
const BString& separator = ", ");
const BString& separator = ", ",
const time_unit_style style = B_TIME_UNIT_FULL);
BDurationFormat(const BString& separator = ", ",
const time_unit_style style = B_TIME_UNIT_FULL);
BDurationFormat(const BDurationFormat& other);
virtual ~BDurationFormat();
@@ -39,8 +40,7 @@ public:
status_t Format(BString& buffer,
const bigtime_t startValue,
const bigtime_t stopValue,
time_unit_style style = B_TIME_UNIT_FULL
const bigtime_t stopValue
) const;
private:
+5 -4
View File
@@ -43,16 +43,17 @@ class BTimeUnitFormat : public BFormat {
typedef BFormat Inherited;
public:
BTimeUnitFormat();
BTimeUnitFormat(const time_unit_style style =
B_TIME_UNIT_FULL);
BTimeUnitFormat(const BLanguage& language,
const BFormattingConventions& conventions);
const BFormattingConventions& conventions,
const time_unit_style style = B_TIME_UNIT_FULL);
BTimeUnitFormat(const BTimeUnitFormat& other);
virtual ~BTimeUnitFormat();
status_t Format(BString& buffer,
const int32 value,
const time_unit_element unit,
time_unit_style style = B_TIME_UNIT_FULL
const time_unit_element unit
) const;
private: