xref: /haiku/docs/user/locale/DurationFormat.dox (revision 400a2a18134996a50644e12a8cae11e53534fdfc)
1c6478376SAdrien Destugues/*
2c6478376SAdrien Destugues * Copyright 2011, Haiku. All rights reserved.
3c6478376SAdrien Destugues * Distributed under the terms of the MIT License.
4c6478376SAdrien Destugues *
5c6478376SAdrien Destugues * Authors:
6c6478376SAdrien Destugues *		Adrien Destugues, pulkomandy@pulkomandy.ath.cx
793ebe763SJohn Scipione *		John Scipione, jscipione@gmail.com
8c6478376SAdrien Destugues *
9c6478376SAdrien Destugues * Corresponds to:
1093ebe763SJohn Scipione *		/trunk/headers/os/locale/DurationFormat.h	 hrev45084
1193ebe763SJohn Scipione *		/trunk/src/kits/locale/DurationFormat.cpp	 hrev45084
12c6478376SAdrien Destugues */
13c6478376SAdrien Destugues
14c6478376SAdrien Destugues
15c6478376SAdrien Destugues/*!
16c6478376SAdrien Destugues	\class BDurationFormat
17c6478376SAdrien Destugues	\ingroup locale
1893ebe763SJohn Scipione	\ingroup libbe
1993ebe763SJohn Scipione	\brief Formatter for time intervals.
20c6478376SAdrien Destugues
2193ebe763SJohn Scipione	BDurationFormat is a formatter for time intervals. A time interval is
2293ebe763SJohn Scipione	defined by its start and end values, and the result is a string such as
23c6478376SAdrien Destugues	"1 hour, 2 minutes, 28 seconds".
24c6478376SAdrien Destugues*/
25c6478376SAdrien Destugues
26c6478376SAdrien Destugues
27c6478376SAdrien Destugues/*!
28c6478376SAdrien Destugues	\fn BDurationFormat::BDurationFormat(const BString& separator)
29c6478376SAdrien Destugues	\brief Constructor.
30c6478376SAdrien Destugues
3193ebe763SJohn Scipione	\warning Creating a BDurationFormat is a costly operation. Most of the
3293ebe763SJohn Scipione		time want to use the default one through the BLocale class.
33c6478376SAdrien Destugues
3493ebe763SJohn Scipione	\param separator String appended between the duration elements.
35c6478376SAdrien Destugues*/
36c6478376SAdrien Destugues
37c6478376SAdrien Destugues
38c6478376SAdrien Destugues/*!
3993ebe763SJohn Scipione	\fn BDurationFormat::BDurationFormat(const BDurationFormat& other)
4093ebe763SJohn Scipione	\brief Copy Constructor.
4193ebe763SJohn Scipione
4293ebe763SJohn Scipione	\param other The BDurationFormat object to copy from.
43c6478376SAdrien Destugues*/
44c6478376SAdrien Destugues
45c6478376SAdrien Destugues
46c6478376SAdrien Destugues/*!
4793ebe763SJohn Scipione	\fn BDurationFormat::~BDurationFormat()
4893ebe763SJohn Scipione	\brief Destructor.
4993ebe763SJohn Scipione*/
5093ebe763SJohn Scipione
5193ebe763SJohn Scipione
5293ebe763SJohn Scipione/*!
53*400a2a18SJohn Scipione	\fn BDurationFormat& BDurationFormat::operator=(const BDurationFormat& other)
5493ebe763SJohn Scipione	\brief Assignment overload.
5593ebe763SJohn Scipione
5693ebe763SJohn Scipione	\param other The BDurationFormat object to copy from.
5793ebe763SJohn Scipione
5893ebe763SJohn Scipione	\returns The resulting BDurationFormat object.
5993ebe763SJohn Scipione*/
6093ebe763SJohn Scipione
6193ebe763SJohn Scipione
6293ebe763SJohn Scipione/*!
6393ebe763SJohn Scipione	\fn void BDurationFormat::SetSeparator(const BString& separator)
6493ebe763SJohn Scipione	\brief Replace the separator for this formatter.
6593ebe763SJohn Scipione
6693ebe763SJohn Scipione	\param separator The separator string to set.
6793ebe763SJohn Scipione*/
6893ebe763SJohn Scipione
6993ebe763SJohn Scipione
7093ebe763SJohn Scipione/*!
7193ebe763SJohn Scipione	\fn status_t BDurationFormat::SetLocale(const BLocale* locale)
72c6478376SAdrien Destugues	\brief Sets the locale for this formatter.
7393ebe763SJohn Scipione
7493ebe763SJohn Scipione	\param locale The BLocale object to set.
7593ebe763SJohn Scipione
7693ebe763SJohn Scipione	\returns A status code, \c B_OK on success or an error code on error.
7793ebe763SJohn Scipione*/
7893ebe763SJohn Scipione
7993ebe763SJohn Scipione
8093ebe763SJohn Scipione/*!
8193ebe763SJohn Scipione	\fn status_t BDurationFormat::SetTimeZone(const BTimeZone* timeZone)
8293ebe763SJohn Scipione	\brief Sets the timezone for this formatter.
8393ebe763SJohn Scipione
8493ebe763SJohn Scipione	\param timeZone The BTimeZone object to set.
8593ebe763SJohn Scipione
8693ebe763SJohn Scipione	\returns A status code.
8793ebe763SJohn Scipione	\retval B_OK Everything went fine.
8893ebe763SJohn Scipione	\retval B_NO_INIT Format object is \c NULL.
8993ebe763SJohn Scipione	\retval B_ERROR Other errors.
90c6478376SAdrien Destugues*/
91c6478376SAdrien Destugues
92c6478376SAdrien Destugues
93c6478376SAdrien Destugues/*!
94c6478376SAdrien Destugues	\fn status_t BDurationFormat::Format(bigtime_t startValue,
9593ebe763SJohn Scipione		bigtime_t stopValue, BString* buffer, time_unit_style style) const
96c6478376SAdrien Destugues	\brief Formats a duration defined by its start and end values.
97c6478376SAdrien Destugues
9893ebe763SJohn Scipione	The start and end values are in milliseconds. The result is appended to
9993ebe763SJohn Scipione	the buffer. The full time style uses full words (hours, minutes, seconds),
10093ebe763SJohn Scipione	while the short one uses units (h, m, s).
10193ebe763SJohn Scipione
10293ebe763SJohn Scipione	\param startValue The start value in milliseconds.
10393ebe763SJohn Scipione	\param stopValue The stop value in milliseconds.
10493ebe763SJohn Scipione	\param buffer The buffer to fill out.
10593ebe763SJohn Scipione	\param style The time unit style to use.
10693ebe763SJohn Scipione
10793ebe763SJohn Scipione	\returns A status code.
10893ebe763SJohn Scipione	\retval B_OK Everything went fine.
10993ebe763SJohn Scipione	\retval B_BAD_VALUE Buffer was \c NULL.
11093ebe763SJohn Scipione	\retval B_ERROR Formatting error.
111c6478376SAdrien Destugues*/
112