Public Member Functions | List of all members
BDurationFormat Class Reference

Formatter for time intervals. More...

Inherits BFormat.

Public Member Functions

 BDurationFormat (const BString &separator=", ")
 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, time_unit_style style=B_TIME_UNIT_FULL) 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::BDurationFormat ( const BString separator = ", ")

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.
Since
Haiku R1
BDurationFormat::BDurationFormat ( const BDurationFormat other)

Copy Constructor.

Parameters
otherThe BDurationFormat object to copy from.
Since
Haiku R1
BDurationFormat::~BDurationFormat ( )
virtual

Destructor.

Since
Haiku R1

Member Function Documentation

status_t BDurationFormat::Format ( BString buffer,
const bigtime_t  startValue,
const bigtime_t  stopValue,
time_unit_style  style = B_TIME_UNIT_FULL 
) 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
startValueThe start value in milliseconds.
stopValueThe stop value in milliseconds.
bufferThe buffer to fill out.
styleThe time unit style to use.
Returns
A status code.
Return values
B_OKEverything went fine.
B_BAD_VALUEbuffer was NULL or invalid.
B_ERRORFormatting error.
Since
Haiku R1
void BDurationFormat::SetSeparator ( const BString separator)

Replace the separator for this formatter.

Parameters
separatorThe separator string to set.
Since
Haiku R1
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