]> git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/unicode/tmunit.h
ICU-59117.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / unicode / tmunit.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 * Copyright (C) 2009-2016, International Business Machines Corporation, *
6 * Google, and others. All Rights Reserved. *
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
24 #if U_SHOW_CPLUSPLUS_API
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,
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 */
52 UTIMEUNIT_FIELD_COUNT
53 #endif // U_HIDE_DEPRECATED_API
54 };
55
56 /**
57 * Create Instance.
58 * @param timeUnitField time unit field based on which the instance
59 * is created.
60 * @param status input-output error code.
61 * If the timeUnitField is invalid,
62 * then this will be set to U_ILLEGAL_ARGUMENT_ERROR.
63 * @return a TimeUnit instance
64 * @stable ICU 4.2
65 */
66 static TimeUnit* U_EXPORT2 createInstance(UTimeUnitFields timeUnitField,
67 UErrorCode& status);
68
69
70 /**
71 * Override clone.
72 * @stable ICU 4.2
73 */
74 virtual UObject* clone() const;
75
76 /**
77 * Copy operator.
78 * @stable ICU 4.2
79 */
80 TimeUnit(const TimeUnit& other);
81
82 /**
83 * Assignment operator.
84 * @stable ICU 4.2
85 */
86 TimeUnit& operator=(const TimeUnit& other);
87
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.
94 * @stable ICU 4.2
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.
102 * @stable ICU 4.2
103 */
104 static UClassID U_EXPORT2 getStaticClassID();
105
106
107 /**
108 * Get time unit field.
109 * @return time unit field.
110 * @stable ICU 4.2
111 */
112 UTimeUnitFields getTimeUnitField() const;
113
114 /**
115 * Destructor.
116 * @stable ICU 4.2
117 */
118 virtual ~TimeUnit();
119
120 private:
121 UTimeUnitFields fTimeUnitField;
122
123 /**
124 * Constructor
125 * @internal (private)
126 */
127 TimeUnit(UTimeUnitFields timeUnitField);
128
129 };
130
131
132 U_NAMESPACE_END
133 #endif // U_SHOW_CPLUSPLUS_API
134
135 #endif /* #if !UCONFIG_NO_FORMATTING */
136
137 #endif // __TMUNIT_H__
138 //eof
139 //