Formatter for time intervals. More...
Inherits BFormat.
Public Member Functions | |
BDurationFormat (const BDurationFormat &other) | |
Copy Constructor. | |
BDurationFormat (const BLanguage &language, const BFormattingConventions &conventions, const BString &separator=", ", const time_unit_style style=B_TIME_UNIT_FULL) | |
Constructor. | |
BDurationFormat (const BString &separator=", ", const time_unit_style style=B_TIME_UNIT_FULL) | |
Constructor. | |
virtual | ~BDurationFormat () |
Destructor. | |
status_t | Format (BString &buffer, const bigtime_t startValue, const bigtime_t stopValue) const |
Formats a duration defined by its start and end values. | |
void | SetSeparator (const BString &separator) |
Replace the separator for this formatter. | |
status_t | SetTimeZone (const BTimeZone *timeZone) |
Sets the timezone for this formatter. | |
Formatter for time intervals.
BDurationFormat is a formatter for time intervals. A time interval is defined by its start and end values, and the result is a string such as "1 hour, 2 minutes, 28 seconds".
BDurationFormat::BDurationFormat | ( | const BLanguage & | language, |
const BFormattingConventions & | conventions, | ||
const BString & | separator = ", " , |
||
const time_unit_style | style = B_TIME_UNIT_FULL |
||
) |
Constructor.
language | The language to use. |
conventions | The formatting conventions to use. |
separator | String appended between the duration elements. |
style | The time unit style to use. |
BDurationFormat::BDurationFormat | ( | const BString & | separator = ", " , |
const time_unit_style | style = B_TIME_UNIT_FULL |
||
) |
Constructor.
separator | String appended between the duration elements. |
style | The time unit style to use. |
BDurationFormat::BDurationFormat | ( | const BDurationFormat & | other | ) |
|
virtual |
Destructor.
status_t BDurationFormat::Format | ( | BString & | buffer, |
const bigtime_t | startValue, | ||
const bigtime_t | stopValue | ||
) | const |
Formats a duration defined by its start and end values.
The start and end values are in milliseconds. The result is appended to the buffer. The full time style uses full words (hours, minutes, seconds), while the short one uses units (h, m, s).
buffer | The buffer to fill out. |
startValue | The start value in milliseconds. |
stopValue | The stop value in milliseconds. |
B_OK | Everything went fine. |
B_BAD_VALUE | buffer was NULL or invalid. |
B_ERROR | Formatting error. |
void BDurationFormat::SetSeparator | ( | const BString & | separator | ) |
Replace the separator for this formatter.
separator | The separator string to set. |