Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var Utils = {
// …
formatDistance: function(distanceInMeters) {
if (distanceInMeters < 1000) {
return distanceInMeters + 'm';
} else {
return (distanceInMeters / 1000).toFixed(1) + 'km';
}
},
formatDuration: function(durationInSeconds) {
var hours = Math.floor(durationInSeconds / 3600);
var minutes = Math.floor(durationInSeconds % 3600 / 60);
if (hours > 0) {
return hours + 'h ' + minutes + 'min';
} else {
return minutes + 'min';
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.