]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
729e4ab9 A |
3 | /* |
4 | ******************************************************************************* | |
2ca993e8 A |
5 | * Copyright (C) 2009-2016, International Business Machines Corporation, * |
6 | * Google, and others. All Rights Reserved. * | |
729e4ab9 A |
7 | ******************************************************************************* |
8 | */ | |
9 | ||
10 | #ifndef __TMUNIT_H__ | |
11 | #define __TMUNIT_H__ | |
12 | ||
13 | ||
14 | /** | |
15 | * \file | |
16 | * \brief C++ API: time unit object | |
17 | */ | |
18 | ||
19 | ||
20 | #include "unicode/measunit.h" | |
21 | ||
22 | #if !UCONFIG_NO_FORMATTING | |
23 | ||
f3c0d7a5 | 24 | #if U_SHOW_CPLUSPLUS_API |
729e4ab9 A |
25 | U_NAMESPACE_BEGIN |
26 | ||
27 | /** | |
28 | * Measurement unit for time units. | |
29 | * @see TimeUnitAmount | |
30 | * @see TimeUnit | |
31 | * @stable ICU 4.2 | |
32 | */ | |
33 | class U_I18N_API TimeUnit: public MeasureUnit { | |
34 | public: | |
35 | /** | |
36 | * Constants for all the time units we supported. | |
37 | * @stable ICU 4.2 | |
38 | */ | |
39 | enum UTimeUnitFields { | |
40 | UTIMEUNIT_YEAR, | |
41 | UTIMEUNIT_MONTH, | |
42 | UTIMEUNIT_DAY, | |
43 | UTIMEUNIT_WEEK, | |
44 | UTIMEUNIT_HOUR, | |
45 | UTIMEUNIT_MINUTE, | |
46 | UTIMEUNIT_SECOND, | |
f3c0d7a5 A |
47 | #ifndef U_HIDE_DEPRECATED_API |
48 | /** | |
49 | * One more than the highest normal UTimeUnitFields value. | |
50 | * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. | |
51 | */ | |
729e4ab9 | 52 | UTIMEUNIT_FIELD_COUNT |
f3c0d7a5 | 53 | #endif // U_HIDE_DEPRECATED_API |
729e4ab9 A |
54 | }; |
55 | ||
56 | /** | |
57 | * Create Instance. | |
2ca993e8 | 58 | * @param timeUnitField time unit field based on which the instance |
729e4ab9 | 59 | * is created. |
2ca993e8 | 60 | * @param status input-output error code. |
729e4ab9 A |
61 | * If the timeUnitField is invalid, |
62 | * then this will be set to U_ILLEGAL_ARGUMENT_ERROR. | |
63 | * @return a TimeUnit instance | |
2ca993e8 | 64 | * @stable ICU 4.2 |
729e4ab9 A |
65 | */ |
66 | static TimeUnit* U_EXPORT2 createInstance(UTimeUnitFields timeUnitField, | |
67 | UErrorCode& status); | |
68 | ||
69 | ||
70 | /** | |
71 | * Override clone. | |
2ca993e8 | 72 | * @stable ICU 4.2 |
729e4ab9 A |
73 | */ |
74 | virtual UObject* clone() const; | |
75 | ||
76 | /** | |
77 | * Copy operator. | |
2ca993e8 | 78 | * @stable ICU 4.2 |
729e4ab9 A |
79 | */ |
80 | TimeUnit(const TimeUnit& other); | |
81 | ||
82 | /** | |
83 | * Assignment operator. | |
2ca993e8 | 84 | * @stable ICU 4.2 |
729e4ab9 A |
85 | */ |
86 | TimeUnit& operator=(const TimeUnit& other); | |
87 | ||
729e4ab9 A |
88 | /** |
89 | * Returns a unique class ID for this object POLYMORPHICALLY. | |
90 | * This method implements a simple form of RTTI used by ICU. | |
91 | * @return The class ID for this object. All objects of a given | |
92 | * class have the same class ID. Objects of other classes have | |
93 | * different class IDs. | |
2ca993e8 | 94 | * @stable ICU 4.2 |
729e4ab9 A |
95 | */ |
96 | virtual UClassID getDynamicClassID() const; | |
97 | ||
98 | /** | |
99 | * Returns the class ID for this class. This is used to compare to | |
100 | * the return value of getDynamicClassID(). | |
101 | * @return The class ID for all objects of this class. | |
2ca993e8 | 102 | * @stable ICU 4.2 |
729e4ab9 A |
103 | */ |
104 | static UClassID U_EXPORT2 getStaticClassID(); | |
105 | ||
106 | ||
107 | /** | |
108 | * Get time unit field. | |
109 | * @return time unit field. | |
2ca993e8 | 110 | * @stable ICU 4.2 |
729e4ab9 A |
111 | */ |
112 | UTimeUnitFields getTimeUnitField() const; | |
113 | ||
114 | /** | |
115 | * Destructor. | |
2ca993e8 | 116 | * @stable ICU 4.2 |
729e4ab9 A |
117 | */ |
118 | virtual ~TimeUnit(); | |
119 | ||
120 | private: | |
121 | UTimeUnitFields fTimeUnitField; | |
122 | ||
123 | /** | |
124 | * Constructor | |
2ca993e8 | 125 | * @internal (private) |
729e4ab9 A |
126 | */ |
127 | TimeUnit(UTimeUnitFields timeUnitField); | |
128 | ||
129 | }; | |
130 | ||
131 | ||
729e4ab9 | 132 | U_NAMESPACE_END |
f3c0d7a5 | 133 | #endif // U_SHOW_CPLUSPLUS_API |
729e4ab9 A |
134 | |
135 | #endif /* #if !UCONFIG_NO_FORMATTING */ | |
136 | ||
137 | #endif // __TMUNIT_H__ | |
138 | //eof | |
139 | // |