-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from jovandeginste/add-per-user-units
Add per-user units to the user's profile
- Loading branch information
Showing
21 changed files
with
314 additions
and
73 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package templatehelpers | ||
|
||
import ( | ||
"fmt" | ||
"math" | ||
) | ||
|
||
const ( | ||
milesPerKM = 0.621371192 | ||
feetPerMeter = 3.2808399 | ||
) | ||
|
||
func HumanDistanceMile(d float64) string { | ||
return fmt.Sprintf("%.2f mi", milesPerKM*d/1000) | ||
} | ||
|
||
func HumanSpeedMilePH(mps float64) string { | ||
if mps == 0 { | ||
return InvalidValue | ||
} | ||
|
||
kmph := 3.6 * mps | ||
|
||
return fmt.Sprintf("%.2f mi/h", milesPerKM*kmph) | ||
} | ||
|
||
func HumanTempoMile(mps float64) string { | ||
if mps == 0 { | ||
return InvalidValue | ||
} | ||
|
||
mpm := 1000 / (60 * mps) / milesPerKM | ||
|
||
wholeMinutes := math.Floor(mpm) | ||
seconds := (mpm - wholeMinutes) * 60 | ||
|
||
return fmt.Sprintf("%d:%02d min/mi", int(wholeMinutes), int(seconds)) | ||
} | ||
|
||
func HumanElevationFt(m float64) string { | ||
return fmt.Sprintf("%.2f ft", feetPerMeter*m) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package templatehelpers | ||
|
||
import ( | ||
"fmt" | ||
"math" | ||
) | ||
|
||
func HumanDistanceKM(d float64) string { | ||
return fmt.Sprintf("%.2f km", d/1000) | ||
} | ||
|
||
func HumanSpeedKPH(mps float64) string { | ||
if mps == 0 { | ||
return InvalidValue | ||
} | ||
|
||
kmph := 3.6 * mps | ||
|
||
return fmt.Sprintf("%.2f km/h", kmph) | ||
} | ||
|
||
func HumanTempoKM(mps float64) string { | ||
if mps == 0 { | ||
return InvalidValue | ||
} | ||
|
||
mpk := 1000 / (60 * mps) | ||
|
||
wholeMinutes := math.Floor(mpk) | ||
seconds := (mpk - wholeMinutes) * 60 | ||
|
||
return fmt.Sprintf("%d:%02d min/km", int(wholeMinutes), int(seconds)) | ||
} | ||
|
||
func HumanElevationM(m float64) string { | ||
return fmt.Sprintf("%.2f m", m) | ||
} |
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
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
Oops, something went wrong.