2011-10-29 23:56:05 +04:00
|
|
|
/*
|
2014-12-05 03:13:46 +03:00
|
|
|
* Copyright 2011-2014 Haiku, Inc. All rights reserved.
|
2011-10-29 23:56:05 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Adrien Destugues, pulkomandy@pulkomandy.ath.cx
|
2012-12-25 04:55:26 +04:00
|
|
|
* John Scipione, jscipione@gmail.com
|
2011-10-29 23:56:05 +04:00
|
|
|
*
|
|
|
|
* Corresponds to:
|
2014-12-05 03:13:46 +03:00
|
|
|
* headers/os/locale/DurationFormat.h hrev48439
|
|
|
|
* src/kits/locale/DurationFormat.cpp hrev48439
|
2011-10-29 23:56:05 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
/*!
|
|
|
|
\file DurationFormat.h
|
|
|
|
\ingroup locale
|
|
|
|
\ingroup libbe
|
2014-12-16 05:12:54 +03:00
|
|
|
\brief Contains BDurationFormat class, a time interval formatter and parser.
|
2013-02-07 06:05:00 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-10-29 23:56:05 +04:00
|
|
|
/*!
|
2012-12-25 04:55:26 +04:00
|
|
|
\class BDurationFormat
|
|
|
|
\ingroup locale
|
|
|
|
\ingroup libbe
|
|
|
|
\brief Formatter for time intervals.
|
2011-10-29 23:56:05 +04:00
|
|
|
|
2012-12-25 04:55:26 +04:00
|
|
|
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".
|
2014-06-12 00:48:17 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2011-10-29 23:56:05 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2012-12-25 04:55:26 +04:00
|
|
|
\fn BDurationFormat::BDurationFormat(const BString& separator)
|
|
|
|
\brief Constructor.
|
2011-10-29 23:56:05 +04:00
|
|
|
|
2012-12-25 04:55:26 +04:00
|
|
|
\warning Creating a BDurationFormat is a costly operation. Most of the
|
2014-06-12 00:48:17 +04:00
|
|
|
time want to use the default one through the BLocale class.
|
2011-10-29 23:56:05 +04:00
|
|
|
|
2012-12-25 04:55:26 +04:00
|
|
|
\param separator String appended between the duration elements.
|
2014-06-12 00:48:17 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2011-10-29 23:56:05 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2012-12-25 04:55:26 +04:00
|
|
|
\fn BDurationFormat::BDurationFormat(const BDurationFormat& other)
|
|
|
|
\brief Copy Constructor.
|
|
|
|
|
|
|
|
\param other The BDurationFormat object to copy from.
|
2014-06-12 00:48:17 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2012-12-25 04:55:26 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn BDurationFormat::~BDurationFormat()
|
|
|
|
\brief Destructor.
|
2014-06-12 00:48:17 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2012-12-25 04:55:26 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn void BDurationFormat::SetSeparator(const BString& separator)
|
|
|
|
\brief Replace the separator for this formatter.
|
|
|
|
|
|
|
|
\param separator The separator string to set.
|
2014-06-12 00:48:17 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2011-10-29 23:56:05 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2012-12-25 04:55:26 +04:00
|
|
|
\fn status_t BDurationFormat::SetTimeZone(const BTimeZone* timeZone)
|
|
|
|
\brief Sets the timezone for this formatter.
|
|
|
|
|
|
|
|
\param timeZone The BTimeZone object to set.
|
|
|
|
|
|
|
|
\returns A status code.
|
|
|
|
\retval B_OK Everything went fine.
|
|
|
|
\retval B_NO_INIT Format object is \c NULL.
|
|
|
|
\retval B_ERROR Other errors.
|
2014-06-12 00:48:17 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2012-12-25 04:55:26 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn status_t BDurationFormat::Format(bigtime_t startValue,
|
|
|
|
bigtime_t stopValue, BString* buffer, time_unit_style style) const
|
|
|
|
\brief 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).
|
|
|
|
|
|
|
|
\param startValue The start value in milliseconds.
|
|
|
|
\param stopValue The stop value in milliseconds.
|
|
|
|
\param buffer The buffer to fill out.
|
|
|
|
\param style The time unit style to use.
|
2011-10-29 23:56:05 +04:00
|
|
|
|
2012-12-25 04:55:26 +04:00
|
|
|
\returns A status code.
|
|
|
|
\retval B_OK Everything went fine.
|
2014-12-16 05:12:54 +03:00
|
|
|
\retval B_BAD_VALUE \a buffer was \c NULL or invalid.
|
2012-12-25 04:55:26 +04:00
|
|
|
\retval B_ERROR Formatting error.
|
2014-06-12 00:48:17 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2011-10-29 23:56:05 +04:00
|
|
|
*/
|