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