mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-07 10:05:51 +08:00
disambiguate metric tonne (1,000kg) and US ton (2,000lb)
This commit is contained in:
@@ -78,7 +78,7 @@ int CSamplesPhysicalQuantities::samples()
|
||||
a4.switchUnit(CAngleUnit::deg());
|
||||
qDebug() << a3 << a4;
|
||||
|
||||
CMass w1(1, CMassUnit::t());
|
||||
CMass w1(1, CMassUnit::tonne());
|
||||
CMass w2(w1);
|
||||
w2.switchUnit(CMassUnit::lb());
|
||||
qDebug() << w1 << w1.valueRoundedWithUnit(CMassUnit::kg()) << w2;
|
||||
|
||||
@@ -488,15 +488,25 @@ public:
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Tonne, aka metric tonne (1000kg)
|
||||
* \brief Tonne, aka metric ton (1000kg)
|
||||
* \return
|
||||
*/
|
||||
static const CMassUnit &t()
|
||||
static const CMassUnit &tonne()
|
||||
{
|
||||
static CMassUnit t(QT_TRANSLATE_NOOP("CMeasurementUnit", "tonne"), "t", 1000.0, 3);
|
||||
return t;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Short ton (2000lb) used in the United States
|
||||
* \return
|
||||
*/
|
||||
static const CMassUnit &shortTon()
|
||||
{
|
||||
static CMassUnit ton(QT_TRANSLATE_NOOP("CMeasurementUnit", "short ton"), "ton", 907.18474, 3);
|
||||
return ton;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Pound, aka mass pound
|
||||
* \return
|
||||
@@ -519,7 +529,8 @@ public:
|
||||
u.append(CMassUnit::g());
|
||||
u.append(CMassUnit::kg());
|
||||
u.append(CMassUnit::lb());
|
||||
u.append(CMassUnit::t());
|
||||
u.append(CMassUnit::tonne());
|
||||
u.append(CMassUnit::shortTon());
|
||||
}
|
||||
return u;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ void CTestPhysicalQuantities::massTests()
|
||||
{
|
||||
CMass w1(1000, CMassUnit::kg());
|
||||
CMass w2(w1.value(), CMassUnit::kg());
|
||||
w2.switchUnit(CMassUnit::t());
|
||||
w2.switchUnit(CMassUnit::tonne());
|
||||
QVERIFY2(w2.value() == 1, "1tonne shall be 1000kg");
|
||||
w2.switchUnit(CMassUnit::lb());
|
||||
QVERIFY2(w2.valueRounded(2) == 2204.62, "1tonne shall be 2204pounds");
|
||||
|
||||
Reference in New Issue
Block a user