Skip to content

Commit f46cd8e

Browse files
committed
Initial implementation of MassFormatter.
1 parent a72f61a commit f46cd8e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Foundation/NSMassFormatter.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ open class MassFormatter : Formatter {
6767
// Format a number in kilograms to a localized string with the locale-appropriate unit and an appropriate scale (e.g. 1.2kg = 2.64lb in the US locale).
6868
open func string(fromKilograms numberInKilograms: Double) -> String {
6969
//Convert to the locale-appropriate unit
70-
let unitFromKilograms = unit(fromKilograms: numberInKilograms)
70+
let unitFromKilograms = convertedUnit(fromKilograms: numberInKilograms)
7171

7272
//Map the unit to UnitMass type for conversion later
7373
let unitMassFromKilograms = MassFormatter.unitMass[unitFromKilograms]!
@@ -102,7 +102,7 @@ open class MassFormatter : Formatter {
102102
// Return the locale-appropriate unit, the same unit used by -stringFromKilograms:.
103103
open func unitString(fromKilograms numberInKilograms: Double, usedUnit unitp: UnsafeMutablePointer<Unit>?) -> String {
104104
//Convert to the locale-appropriate unit
105-
let unitFromKilograms = unit(fromKilograms: numberInKilograms)
105+
let unitFromKilograms = convertedUnit(fromKilograms: numberInKilograms)
106106
unitp?.pointee = unitFromKilograms
107107

108108
//Map the unit to UnitMass type for conversion later
@@ -133,7 +133,7 @@ open class MassFormatter : Formatter {
133133
///
134134
/// - Parameter numberInKilograms: the magnitude in terms of kilograms
135135
/// - Returns: Returns the appropriate unit
136-
private func unit(fromKilograms numberInKilograms: Double) -> Unit {
136+
private func convertedUnit(fromKilograms numberInKilograms: Double) -> Unit {
137137
if numberFormatter.locale.sr3202_fix_isMetricSystemLocale() {
138138
if numberInKilograms > 1.0 || numberInKilograms <= 0.0 {
139139
return .kilogram

0 commit comments

Comments
 (0)