Created
May 31, 2018 14:12
-
-
Save XCarbone/c7d42568203b193b5e8893f7274139cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MeasurementFormatter.swift | |
// onTracks | |
// | |
// Created by Xuan Carbone on 31/05/2018. | |
// Copyright © 2018 onTracks. All rights reserved. | |
// | |
import Foundation | |
class MeasureFormatter { | |
func formatMesure(distance: Double) -> String { | |
var distanceToDisplay = "" | |
let formatedDistance = Measurement(value:distance, unit: UnitLength.meters) | |
let languageCode = Locale.current.languageCode | |
let language = languageCode! | |
let countryDistance = MeasurementFormatter() | |
countryDistance.locale = Locale(identifier: "\(language)") | |
distanceToDisplay = "Distance : \(countryDistance.string(from: formatedDistance))" | |
return distanceToDisplay | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment