tmunit.h 3.3 KB

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