2010-08-02 00:28:19 +04:00
|
|
|
/*
|
2011-08-19 02:13:06 +04:00
|
|
|
* Copyright 2010-2011, Haiku, Inc.
|
2010-08-02 00:28:19 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _B_TIME_UNIT_FORMAT_H_
|
|
|
|
#define _B_TIME_UNIT_FORMAT_H_
|
|
|
|
|
|
|
|
|
2010-08-30 00:55:00 +04:00
|
|
|
#include <Format.h>
|
2010-08-02 00:28:19 +04:00
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
|
|
|
|
|
|
class BString;
|
|
|
|
|
2011-08-19 02:13:06 +04:00
|
|
|
namespace icu {
|
2010-08-30 00:55:00 +04:00
|
|
|
class TimeUnitFormat;
|
|
|
|
}
|
|
|
|
|
2010-08-02 00:28:19 +04:00
|
|
|
|
|
|
|
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 {
|
2010-08-30 00:55:00 +04:00
|
|
|
typedef BFormat Inherited;
|
|
|
|
|
2010-08-02 00:28:19 +04:00
|
|
|
public:
|
2010-08-30 00:55:00 +04:00
|
|
|
BTimeUnitFormat();
|
|
|
|
BTimeUnitFormat(const BTimeUnitFormat& other);
|
|
|
|
virtual ~BTimeUnitFormat();
|
|
|
|
|
|
|
|
BTimeUnitFormat& operator=(const BTimeUnitFormat& other);
|
|
|
|
|
|
|
|
virtual status_t SetLocale(const BLocale* locale);
|
2010-08-02 00:28:19 +04:00
|
|
|
status_t Format(int32 value, time_unit_element unit,
|
|
|
|
BString* buffer,
|
|
|
|
time_unit_style style = B_TIME_UNIT_FULL
|
|
|
|
) const;
|
2010-08-30 00:55:00 +04:00
|
|
|
|
|
|
|
private:
|
2011-08-19 02:13:06 +04:00
|
|
|
icu::TimeUnitFormat* fFormatter;
|
2010-08-02 00:28:19 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|