1c6478376SAdrien Destugues/* 24a31c326SJohn Scipione * Copyright 2011-2014 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: 104a31c326SJohn Scipione * headers/os/locale/DurationFormat.h hrev48439 114a31c326SJohn Scipione * src/kits/locale/DurationFormat.cpp hrev48439 12820dca4dSJohn Scipione */ 13820dca4dSJohn Scipione 14820dca4dSJohn Scipione 15820dca4dSJohn Scipione/*! 16820dca4dSJohn Scipione \file DurationFormat.h 17820dca4dSJohn Scipione \ingroup locale 18820dca4dSJohn Scipione \ingroup libbe 1971f6259aSJohn Scipione \brief Contains BDurationFormat class, a time interval formatter and parser. 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". 32edc845a3SJohn Scipione 33edc845a3SJohn Scipione \since Haiku R1 34c6478376SAdrien Destugues*/ 35c6478376SAdrien Destugues 36c6478376SAdrien Destugues 37c6478376SAdrien Destugues/*! 38*e08fce49SJohn Scipione \fn BDurationFormat::BDurationFormat(const BLanguage& language, 39*e08fce49SJohn Scipione const BFormattingConventions& conventions, const BString& separator, 40*e08fce49SJohn Scipione const time_unit_style style) 41*e08fce49SJohn Scipione \brief Constructor. 42*e08fce49SJohn Scipione 43*e08fce49SJohn Scipione \warning Creating a BDurationFormat is a costly operation. Most of the 44*e08fce49SJohn Scipione time want to use the default one through the BLocale class. 45*e08fce49SJohn Scipione 46*e08fce49SJohn Scipione \param language The language to use. 47*e08fce49SJohn Scipione \param conventions The formatting conventions to use. 48*e08fce49SJohn Scipione \param separator String appended between the duration elements. 49*e08fce49SJohn Scipione \param style The time unit style to use. 50*e08fce49SJohn Scipione 51*e08fce49SJohn Scipione \since Haiku R1 52*e08fce49SJohn Scipione*/ 53*e08fce49SJohn Scipione 54*e08fce49SJohn Scipione 55*e08fce49SJohn Scipione/*! 56*e08fce49SJohn Scipione \fn BDurationFormat::BDurationFormat(const BString& separator, 57*e08fce49SJohn Scipione const time_unit_style style) 58c6478376SAdrien Destugues \brief Constructor. 59c6478376SAdrien Destugues 6093ebe763SJohn Scipione \warning Creating a BDurationFormat is a costly operation. Most of the 6193ebe763SJohn Scipione time want to use the default one through the BLocale class. 62c6478376SAdrien Destugues 6393ebe763SJohn Scipione \param separator String appended between the duration elements. 64*e08fce49SJohn Scipione \param style The time unit style to use. 65edc845a3SJohn Scipione 66edc845a3SJohn Scipione \since Haiku R1 67c6478376SAdrien Destugues*/ 68c6478376SAdrien Destugues 69c6478376SAdrien Destugues 70c6478376SAdrien Destugues/*! 7193ebe763SJohn Scipione \fn BDurationFormat::BDurationFormat(const BDurationFormat& other) 7293ebe763SJohn Scipione \brief Copy Constructor. 7393ebe763SJohn Scipione 7493ebe763SJohn Scipione \param other The BDurationFormat object to copy from. 75edc845a3SJohn Scipione 76edc845a3SJohn Scipione \since Haiku R1 77c6478376SAdrien Destugues*/ 78c6478376SAdrien Destugues 79c6478376SAdrien Destugues 80c6478376SAdrien Destugues/*! 8193ebe763SJohn Scipione \fn BDurationFormat::~BDurationFormat() 8293ebe763SJohn Scipione \brief Destructor. 83edc845a3SJohn Scipione 84edc845a3SJohn Scipione \since Haiku R1 8593ebe763SJohn Scipione*/ 8693ebe763SJohn Scipione 8793ebe763SJohn Scipione 8893ebe763SJohn Scipione/*! 8993ebe763SJohn Scipione \fn void BDurationFormat::SetSeparator(const BString& separator) 9093ebe763SJohn Scipione \brief Replace the separator for this formatter. 9193ebe763SJohn Scipione 9293ebe763SJohn Scipione \param separator The separator string to set. 93edc845a3SJohn Scipione 94edc845a3SJohn Scipione \since Haiku R1 9593ebe763SJohn Scipione*/ 9693ebe763SJohn Scipione 9793ebe763SJohn Scipione 9893ebe763SJohn Scipione/*! 9993ebe763SJohn Scipione \fn status_t BDurationFormat::SetTimeZone(const BTimeZone* timeZone) 10093ebe763SJohn Scipione \brief Sets the timezone for this formatter. 10193ebe763SJohn Scipione 10293ebe763SJohn Scipione \param timeZone The BTimeZone object to set. 10393ebe763SJohn Scipione 10493ebe763SJohn Scipione \returns A status code. 10593ebe763SJohn Scipione \retval B_OK Everything went fine. 10693ebe763SJohn Scipione \retval B_NO_INIT Format object is \c NULL. 10793ebe763SJohn Scipione \retval B_ERROR Other errors. 108edc845a3SJohn Scipione 109edc845a3SJohn Scipione \since Haiku R1 110c6478376SAdrien Destugues*/ 111c6478376SAdrien Destugues 112c6478376SAdrien Destugues 113c6478376SAdrien Destugues/*! 114c6478376SAdrien Destugues \fn status_t BDurationFormat::Format(bigtime_t startValue, 11593ebe763SJohn Scipione bigtime_t stopValue, BString* buffer, time_unit_style style) const 116c6478376SAdrien Destugues \brief Formats a duration defined by its start and end values. 117c6478376SAdrien Destugues 11893ebe763SJohn Scipione The start and end values are in milliseconds. The result is appended to 11993ebe763SJohn Scipione the buffer. The full time style uses full words (hours, minutes, seconds), 12093ebe763SJohn Scipione while the short one uses units (h, m, s). 12193ebe763SJohn Scipione 12293ebe763SJohn Scipione \param startValue The start value in milliseconds. 12393ebe763SJohn Scipione \param stopValue The stop value in milliseconds. 12493ebe763SJohn Scipione \param buffer The buffer to fill out. 12593ebe763SJohn Scipione \param style The time unit style to use. 12693ebe763SJohn Scipione 12793ebe763SJohn Scipione \returns A status code. 12893ebe763SJohn Scipione \retval B_OK Everything went fine. 12971f6259aSJohn Scipione \retval B_BAD_VALUE \a buffer was \c NULL or invalid. 13093ebe763SJohn Scipione \retval B_ERROR Formatting error. 131edc845a3SJohn Scipione 132edc845a3SJohn Scipione \since Haiku R1 133c6478376SAdrien Destugues*/ 134