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