5d5ec05b1d
The language and formatting conventions can now only be set when creating the objects. This removed the needs for locking them when formatting to avoid some other thread changing the format while it's being used. Adjust tests and DeskBar TimeView to the API changes.
61 lines
1.1 KiB
C++
61 lines
1.1 KiB
C++
/*
|
|
* Copyright 2010-2011, Haiku, Inc.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _B_TIME_UNIT_FORMAT_H_
|
|
#define _B_TIME_UNIT_FORMAT_H_
|
|
|
|
|
|
#include <Format.h>
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
class BString;
|
|
|
|
namespace icu {
|
|
class TimeUnitFormat;
|
|
}
|
|
|
|
|
|
enum time_unit_style {
|
|
B_TIME_UNIT_ABBREVIATED, // e.g. '5 hrs.'
|
|
B_TIME_UNIT_FULL, // e.g. '5 hours'
|
|
};
|
|
|
|
|
|
enum time_unit_element {
|
|
B_TIME_UNIT_YEAR,
|
|
B_TIME_UNIT_MONTH,
|
|
B_TIME_UNIT_WEEK,
|
|
B_TIME_UNIT_DAY,
|
|
B_TIME_UNIT_HOUR,
|
|
B_TIME_UNIT_MINUTE,
|
|
B_TIME_UNIT_SECOND,
|
|
|
|
B_TIME_UNIT_LAST = B_TIME_UNIT_SECOND
|
|
};
|
|
|
|
|
|
class BTimeUnitFormat : public BFormat {
|
|
typedef BFormat Inherited;
|
|
|
|
public:
|
|
BTimeUnitFormat();
|
|
BTimeUnitFormat(const BLanguage& language,
|
|
const BFormattingConventions& conventions);
|
|
BTimeUnitFormat(const BTimeUnitFormat& other);
|
|
virtual ~BTimeUnitFormat();
|
|
|
|
status_t Format(BString& buffer,
|
|
const int32 value,
|
|
const time_unit_element unit,
|
|
time_unit_style style = B_TIME_UNIT_FULL
|
|
) const;
|
|
|
|
private:
|
|
icu::TimeUnitFormat* fFormatter;
|
|
};
|
|
|
|
|
|
#endif
|