Public Member Functions
BDurationFormat Class Reference

Formatter for time intervals. More...

Inherits BFormat.

List of all members.

Public Member Functions

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

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


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

Copy Constructor.

Parameters:
otherThe BDurationFormat object to copy from.

Member Function Documentation

status_t BDurationFormat::Format ( bigtime_t  startValue,
bigtime_t  stopValue,
BString buffer,
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.
B_ERRORFormatting error.
BDurationFormat & BDurationFormat::operator= ( const BDurationFormat other)

Assignment overload.

Parameters:
otherThe BDurationFormat object to copy from.
Returns:
The resulting BDurationFormat object.
status_t BDurationFormat::SetLocale ( const BLocale locale) [virtual]

Sets the locale for this formatter.

Parameters:
localeThe BLocale object to set.
Returns:
A status code, B_OK on success or an error code on error.
void BDurationFormat::SetSeparator ( const BString separator)

Replace the separator for this formatter.

Parameters:
separatorThe separator string to set.
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.

The Haiku Book pre-R1 - BDurationFormat Class Reference
Generated on Sun May 19 2013 by Doxygen 1.7.5.1