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