Public Member Functions | List of all members
BDurationFormat Class Reference

Formatter for time intervals. More...

Inherits BFormat.

Public Member Functions

 BDurationFormat (const BLanguage &language, const BFormattingConventions &conventions, const BString &separator=", ", const time_unit_style style=B_TIME_UNIT_FULL)
 Constructor. More...
 
 BDurationFormat (const BString &separator=", ", const time_unit_style style=B_TIME_UNIT_FULL)
 Constructor. More...
 
 BDurationFormat (const BDurationFormat &other)
 Copy Constructor. More...
 
virtual ~BDurationFormat ()
 Destructor. More...
 
status_t Format (BString &buffer, const bigtime_t startValue, const bigtime_t stopValue) const
 Formats a duration defined by its start and end values. More...
 
void SetSeparator (const BString &separator)
 Replace the separator for this formatter. More...
 
status_t SetTimeZone (const BTimeZone *timeZone)
 Sets the timezone for this formatter. More...
 

Detailed Description

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".

Since
Haiku R1

Constructor & Destructor Documentation

◆ BDurationFormat() [1/3]

BDurationFormat::BDurationFormat ( const BLanguage &  language,
const BFormattingConventions &  conventions,
const BString separator = ", ",
const time_unit_style  style = B_TIME_UNIT_FULL 
)

Constructor.

Warning
Creating a BDurationFormat is a costly operation. Most of the time want to use the default one through the BLocale class.
Parameters
languageThe language to use.
conventionsThe formatting conventions to use.
separatorString appended between the duration elements.
styleThe time unit style to use.
Since
Haiku R1

◆ BDurationFormat() [2/3]

BDurationFormat::BDurationFormat ( const BString separator = ", ",
const time_unit_style  style = B_TIME_UNIT_FULL 
)

Constructor.

Warning
Creating a BDurationFormat is a costly operation. Most of the time want to use the default one through the BLocale class.
Parameters
separatorString appended between the duration elements.
styleThe time unit style to use.
Since
Haiku R1

◆ BDurationFormat() [3/3]

BDurationFormat::BDurationFormat ( const BDurationFormat other)

Copy Constructor.

Parameters
otherThe BDurationFormat object to copy from.
Since
Haiku R1

◆ ~BDurationFormat()

BDurationFormat::~BDurationFormat ( )
virtual

Destructor.

Since
Haiku R1

Member Function Documentation

◆ Format()

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).

Parameters
bufferThe buffer to fill out.
startValueThe start value in milliseconds.
stopValueThe stop value in milliseconds.
Returns
A status code.
Return values
B_OKEverything went fine.
B_BAD_VALUEbuffer was NULL or invalid.
B_ERRORFormatting error.
Since
Haiku R1

◆ SetSeparator()

void BDurationFormat::SetSeparator ( const BString separator)

Replace the separator for this formatter.

Parameters
separatorThe separator string to set.
Since
Haiku R1

◆ SetTimeZone()

status_t BDurationFormat::SetTimeZone ( const BTimeZone timeZone)

Sets the timezone for this formatter.

Parameters
timeZoneThe BTimeZone object to set.
Returns
A status code.
Return values
B_OKEverything went fine.
B_NO_INITFormat object is NULL.
B_ERROROther errors.
Since
Haiku R1