haiku/headers/os/locale/DurationFormat.h
Adrien Destugues 44f11d0982 Make BDateFormat inherit from BFormat again
* Move relevant parts up into BFormat so other format classes can use
those
* Adjust BDurationFormat and BTimeUnitFormat for the changes
* Remove the "default" date format, it is better to keep only a default
locale and let applications create B*Formats from it as needed.
* Creating a B*Format without arguments to the constructor now
configures it for the default locale, which allows for easy use in
standard cases (formatting something with the current language and
format)
* Creating a B*Format is potentially an expansive operation, it is
advised to keep the instance around and reuse it whenever possible.
However it must be "refreshed" when the locale changes, for apps which
supports that, since it keeps a copy of the language and formatting
convention, rather than a pointer to the locale as it did before.
2014-10-01 16:29:12 +02:00

51 lines
1.0 KiB
C++

/*
* Copyright 2010-2011, Haiku, Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _B_DURATION_FORMAT_H_
#define _B_DURATION_FORMAT_H_
#include <Format.h>
#include <Locale.h>
#include <String.h>
#include <TimeUnitFormat.h>
class BTimeZone;
namespace icu {
class GregorianCalendar;
}
class BDurationFormat : public BFormat {
typedef BFormat Inherited;
public:
BDurationFormat(
const BString& separator = ", ");
BDurationFormat(const BDurationFormat& other);
virtual ~BDurationFormat();
BDurationFormat& operator=(const BDurationFormat& other);
void SetSeparator(const BString& separator);
virtual status_t SetLanguage(const BLanguage& language);
status_t SetTimeZone(const BTimeZone* timeZone);
status_t Format(bigtime_t startValue,
bigtime_t stopValue, BString* buffer,
time_unit_style style = B_TIME_UNIT_FULL
) const;
private:
BString fSeparator;
BTimeUnitFormat fTimeUnitFormat;
icu::GregorianCalendar* fCalendar;
};
#endif