xref: /haiku/headers/os/locale/TimeUnitFormat.h (revision f5c544b59a75f9d2912f158fad8a4cbc9ddc55da)
1 /*
2  * Copyright 2010-2011, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _B_TIME_UNIT_FORMAT_H_
6 #define _B_TIME_UNIT_FORMAT_H_
7 
8 
9 #include <Format.h>
10 #include <SupportDefs.h>
11 
12 
13 class BString;
14 
15 #ifndef U_ICU_NAMESPACE
16   #define U_ICU_NAMESPACE icu
17 #endif
18 namespace U_ICU_NAMESPACE {
19 	class TimeUnitFormat;
20 }
21 
22 
23 enum time_unit_style {
24 	B_TIME_UNIT_ABBREVIATED,	// e.g. '5 hrs.'
25 	B_TIME_UNIT_FULL,			// e.g. '5 hours'
26 };
27 
28 
29 enum time_unit_element {
30 	B_TIME_UNIT_YEAR,
31 	B_TIME_UNIT_MONTH,
32 	B_TIME_UNIT_WEEK,
33 	B_TIME_UNIT_DAY,
34 	B_TIME_UNIT_HOUR,
35 	B_TIME_UNIT_MINUTE,
36 	B_TIME_UNIT_SECOND,
37 
38 	B_TIME_UNIT_LAST = B_TIME_UNIT_SECOND
39 };
40 
41 
42 class BTimeUnitFormat : public BFormat {
43 	typedef	BFormat				Inherited;
44 
45 public:
46 								BTimeUnitFormat(const time_unit_style style =
47 									B_TIME_UNIT_FULL);
48 								BTimeUnitFormat(const BLanguage& language,
49 									const BFormattingConventions& conventions,
50 									const time_unit_style style = B_TIME_UNIT_FULL);
51 								BTimeUnitFormat(const BTimeUnitFormat& other);
52 	virtual						~BTimeUnitFormat();
53 
54 			status_t			Format(BString& buffer,
55 									const int32 value,
56 									const time_unit_element unit
57 									) const;
58 
59 private:
60 			U_ICU_NAMESPACE::TimeUnitFormat*	fFormatter;
61 };
62 
63 
64 #endif
65