1c6478376SAdrien Destugues/* 2820dca4dSJohn Scipione * Copyright 2011 Haiku, Inc. 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: 10820dca4dSJohn Scipione * headers/os/locale/DurationFormat.h hrev45084 11820dca4dSJohn Scipione * src/kits/locale/DurationFormat.cpp hrev45084 12820dca4dSJohn Scipione */ 13820dca4dSJohn Scipione 14820dca4dSJohn Scipione 15820dca4dSJohn Scipione/*! 16820dca4dSJohn Scipione \file DurationFormat.h 17820dca4dSJohn Scipione \ingroup locale 18820dca4dSJohn Scipione \ingroup libbe 19820dca4dSJohn Scipione \brief Contains BDurationFormat class, a time interval formatter. 20c6478376SAdrien Destugues*/ 21c6478376SAdrien Destugues 22c6478376SAdrien Destugues 23c6478376SAdrien Destugues/*! 24c6478376SAdrien Destugues \class BDurationFormat 25c6478376SAdrien Destugues \ingroup locale 2693ebe763SJohn Scipione \ingroup libbe 2793ebe763SJohn Scipione \brief Formatter for time intervals. 28c6478376SAdrien Destugues 2993ebe763SJohn Scipione BDurationFormat is a formatter for time intervals. A time interval is 3093ebe763SJohn Scipione defined by its start and end values, and the result is a string such as 31c6478376SAdrien Destugues "1 hour, 2 minutes, 28 seconds". 32*edc845a3SJohn Scipione 33*edc845a3SJohn Scipione \since Haiku R1 34c6478376SAdrien Destugues*/ 35c6478376SAdrien Destugues 36c6478376SAdrien Destugues 37c6478376SAdrien Destugues/*! 38c6478376SAdrien Destugues \fn BDurationFormat::BDurationFormat(const BString& separator) 39c6478376SAdrien Destugues \brief Constructor. 40c6478376SAdrien Destugues 4193ebe763SJohn Scipione \warning Creating a BDurationFormat is a costly operation. Most of the 4293ebe763SJohn Scipione time want to use the default one through the BLocale class. 43c6478376SAdrien Destugues 4493ebe763SJohn Scipione \param separator String appended between the duration elements. 45*edc845a3SJohn Scipione 46*edc845a3SJohn Scipione \since Haiku R1 47c6478376SAdrien Destugues*/ 48c6478376SAdrien Destugues 49c6478376SAdrien Destugues 50c6478376SAdrien Destugues/*! 5193ebe763SJohn Scipione \fn BDurationFormat::BDurationFormat(const BDurationFormat& other) 5293ebe763SJohn Scipione \brief Copy Constructor. 5393ebe763SJohn Scipione 5493ebe763SJohn Scipione \param other The BDurationFormat object to copy from. 55*edc845a3SJohn Scipione 56*edc845a3SJohn Scipione \since Haiku R1 57c6478376SAdrien Destugues*/ 58c6478376SAdrien Destugues 59c6478376SAdrien Destugues 60c6478376SAdrien Destugues/*! 6193ebe763SJohn Scipione \fn BDurationFormat::~BDurationFormat() 6293ebe763SJohn Scipione \brief Destructor. 63*edc845a3SJohn Scipione 64*edc845a3SJohn Scipione \since Haiku R1 6593ebe763SJohn Scipione*/ 6693ebe763SJohn Scipione 6793ebe763SJohn Scipione 6893ebe763SJohn Scipione/*! 69400a2a18SJohn Scipione \fn BDurationFormat& BDurationFormat::operator=(const BDurationFormat& other) 7093ebe763SJohn Scipione \brief Assignment overload. 7193ebe763SJohn Scipione 7293ebe763SJohn Scipione \param other The BDurationFormat object to copy from. 7393ebe763SJohn Scipione 7493ebe763SJohn Scipione \returns The resulting BDurationFormat object. 75*edc845a3SJohn Scipione 76*edc845a3SJohn Scipione \since Haiku R1 7793ebe763SJohn Scipione*/ 7893ebe763SJohn Scipione 7993ebe763SJohn Scipione 8093ebe763SJohn Scipione/*! 8193ebe763SJohn Scipione \fn void BDurationFormat::SetSeparator(const BString& separator) 8293ebe763SJohn Scipione \brief Replace the separator for this formatter. 8393ebe763SJohn Scipione 8493ebe763SJohn Scipione \param separator The separator string to set. 85*edc845a3SJohn Scipione 86*edc845a3SJohn Scipione \since Haiku R1 8793ebe763SJohn Scipione*/ 8893ebe763SJohn Scipione 8993ebe763SJohn Scipione 9093ebe763SJohn Scipione/*! 9193ebe763SJohn Scipione \fn status_t BDurationFormat::SetLocale(const BLocale* locale) 92c6478376SAdrien Destugues \brief Sets the locale for this formatter. 9393ebe763SJohn Scipione 9493ebe763SJohn Scipione \param locale The BLocale object to set. 9593ebe763SJohn Scipione 9693ebe763SJohn Scipione \returns A status code, \c B_OK on success or an error code on error. 97*edc845a3SJohn Scipione 98*edc845a3SJohn Scipione \since Haiku R1 9993ebe763SJohn Scipione*/ 10093ebe763SJohn Scipione 10193ebe763SJohn Scipione 10293ebe763SJohn Scipione/*! 10393ebe763SJohn Scipione \fn status_t BDurationFormat::SetTimeZone(const BTimeZone* timeZone) 10493ebe763SJohn Scipione \brief Sets the timezone for this formatter. 10593ebe763SJohn Scipione 10693ebe763SJohn Scipione \param timeZone The BTimeZone object to set. 10793ebe763SJohn Scipione 10893ebe763SJohn Scipione \returns A status code. 10993ebe763SJohn Scipione \retval B_OK Everything went fine. 11093ebe763SJohn Scipione \retval B_NO_INIT Format object is \c NULL. 11193ebe763SJohn Scipione \retval B_ERROR Other errors. 112*edc845a3SJohn Scipione 113*edc845a3SJohn Scipione \since Haiku R1 114c6478376SAdrien Destugues*/ 115c6478376SAdrien Destugues 116c6478376SAdrien Destugues 117c6478376SAdrien Destugues/*! 118c6478376SAdrien Destugues \fn status_t BDurationFormat::Format(bigtime_t startValue, 11993ebe763SJohn Scipione bigtime_t stopValue, BString* buffer, time_unit_style style) const 120c6478376SAdrien Destugues \brief Formats a duration defined by its start and end values. 121c6478376SAdrien Destugues 12293ebe763SJohn Scipione The start and end values are in milliseconds. The result is appended to 12393ebe763SJohn Scipione the buffer. The full time style uses full words (hours, minutes, seconds), 12493ebe763SJohn Scipione while the short one uses units (h, m, s). 12593ebe763SJohn Scipione 12693ebe763SJohn Scipione \param startValue The start value in milliseconds. 12793ebe763SJohn Scipione \param stopValue The stop value in milliseconds. 12893ebe763SJohn Scipione \param buffer The buffer to fill out. 12993ebe763SJohn Scipione \param style The time unit style to use. 13093ebe763SJohn Scipione 13193ebe763SJohn Scipione \returns A status code. 13293ebe763SJohn Scipione \retval B_OK Everything went fine. 13393ebe763SJohn Scipione \retval B_BAD_VALUE Buffer was \c NULL. 13493ebe763SJohn Scipione \retval B_ERROR Formatting error. 135*edc845a3SJohn Scipione 136*edc845a3SJohn Scipione \since Haiku R1 137c6478376SAdrien Destugues*/ 138