1 // © 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 
10 #include "unicode/tmutamt.h"
11 
12 #if !UCONFIG_NO_FORMATTING
13 
14 U_NAMESPACE_BEGIN
15 
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TimeUnitAmount)16 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TimeUnitAmount)
17 
18 
19 TimeUnitAmount::TimeUnitAmount(const Formattable& number,
20                                TimeUnit::UTimeUnitFields timeUnitField,
21                                UErrorCode& status)
22 :    Measure(number, TimeUnit::createInstance(timeUnitField, status), status) {
23 }
24 
25 
TimeUnitAmount(double amount,TimeUnit::UTimeUnitFields timeUnitField,UErrorCode & status)26 TimeUnitAmount::TimeUnitAmount(double amount,
27                                TimeUnit::UTimeUnitFields timeUnitField,
28                                UErrorCode& status)
29 :   Measure(Formattable(amount),
30             TimeUnit::createInstance(timeUnitField, status),
31             status) {
32 }
33 
34 
TimeUnitAmount(const TimeUnitAmount & other)35 TimeUnitAmount::TimeUnitAmount(const TimeUnitAmount& other)
36 :   Measure(other)
37 {
38 }
39 
40 
41 TimeUnitAmount&
operator =(const TimeUnitAmount & other)42 TimeUnitAmount::operator=(const TimeUnitAmount& other) {
43     Measure::operator=(other);
44     return *this;
45 }
46 
47 
48 UBool
operator ==(const UObject & other) const49 TimeUnitAmount::operator==(const UObject& other) const {
50     return Measure::operator==(other);
51 }
52 
53 TimeUnitAmount*
clone() const54 TimeUnitAmount::clone() const {
55     return new TimeUnitAmount(*this);
56 }
57 
58 
~TimeUnitAmount()59 TimeUnitAmount::~TimeUnitAmount() {
60 }
61 
62 
63 
64 const TimeUnit&
getTimeUnit() const65 TimeUnitAmount::getTimeUnit() const {
66     return (const TimeUnit&) getUnit();
67 }
68 
69 
70 TimeUnit::UTimeUnitFields
getTimeUnitField() const71 TimeUnitAmount::getTimeUnitField() const {
72     return getTimeUnit().getTimeUnitField();
73 }
74 
75 
76 U_NAMESPACE_END
77 
78 #endif
79