src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

units.go (609B)


      1 package entry
      2 
      3 import (
      4 	"code.dwrz.net/src/pkg/dqs/stats"
      5 	"code.dwrz.net/src/pkg/dqs/user/units"
      6 )
      7 
      8 func (e *Entry) UnitBodyFatWeight(system units.System) float64 {
      9 	bfw := stats.BodyFatWeight(e.Weight, e.BodyFat)
     10 
     11 	if system == units.Metric {
     12 		return bfw
     13 	}
     14 
     15 	return units.KilogramToPounds(bfw)
     16 }
     17 
     18 func (e *Entry) UnitHeight(system units.System) float64 {
     19 	if system == units.Metric {
     20 		return e.Height
     21 	}
     22 
     23 	return units.CentimeterToInches(e.Height)
     24 }
     25 
     26 func (e *Entry) UnitWeight(system units.System) float64 {
     27 	if system == units.Metric {
     28 		return e.Weight
     29 	}
     30 
     31 	return units.KilogramToPounds(e.Weight)
     32 }