tmutamt.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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) 2008, Google, International Business Machines Corporation and *
  6. * others. All Rights Reserved. *
  7. *******************************************************************************
  8. */
  9. #include "unicode/tmutamt.h"
  10. #if !UCONFIG_NO_FORMATTING
  11. U_NAMESPACE_BEGIN
  12. UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TimeUnitAmount)
  13. TimeUnitAmount::TimeUnitAmount(const Formattable& number,
  14. TimeUnit::UTimeUnitFields timeUnitField,
  15. UErrorCode& status)
  16. : Measure(number, TimeUnit::createInstance(timeUnitField, status), status) {
  17. }
  18. TimeUnitAmount::TimeUnitAmount(double amount,
  19. TimeUnit::UTimeUnitFields timeUnitField,
  20. UErrorCode& status)
  21. : Measure(Formattable(amount),
  22. TimeUnit::createInstance(timeUnitField, status),
  23. status) {
  24. }
  25. TimeUnitAmount::TimeUnitAmount(const TimeUnitAmount& other)
  26. : Measure(other)
  27. {
  28. }
  29. TimeUnitAmount&
  30. TimeUnitAmount::operator=(const TimeUnitAmount& other) {
  31. Measure::operator=(other);
  32. return *this;
  33. }
  34. UBool
  35. TimeUnitAmount::operator==(const UObject& other) const {
  36. return Measure::operator==(other);
  37. }
  38. UObject*
  39. TimeUnitAmount::clone() const {
  40. return new TimeUnitAmount(*this);
  41. }
  42. TimeUnitAmount::~TimeUnitAmount() {
  43. }
  44. const TimeUnit&
  45. TimeUnitAmount::getTimeUnit() const {
  46. return (const TimeUnit&) getUnit();
  47. }
  48. TimeUnit::UTimeUnitFields
  49. TimeUnitAmount::getTimeUnitField() const {
  50. return getTimeUnit().getTimeUnitField();
  51. }
  52. U_NAMESPACE_END
  53. #endif