src

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

units.go (703B)


      1 package user
      2 
      3 import (
      4 	"code.dwrz.net/src/pkg/dqs/stats"
      5 	"code.dwrz.net/src/pkg/dqs/user/units"
      6 )
      7 
      8 func (u *User) UnitBodyFatWeight() float64 {
      9 	bfw := stats.BodyFatWeight(u.Weight, u.BodyFat)
     10 
     11 	if u.Units == units.Metric {
     12 		return bfw
     13 	}
     14 
     15 	return units.KilogramToPounds(bfw)
     16 }
     17 
     18 func (u *User) UnitHeight() float64 {
     19 	if u.Units == units.Metric {
     20 		return u.Height
     21 	}
     22 
     23 	return units.CentimeterToInches(u.Height)
     24 }
     25 
     26 func (u *User) UnitTargetWeight() float64 {
     27 	if u.Units == units.Metric {
     28 		return u.TargetWeight
     29 	}
     30 
     31 	return units.KilogramToPounds(u.TargetWeight)
     32 }
     33 
     34 func (u *User) UnitWeight() float64 {
     35 	if u.Units == units.Metric {
     36 		return u.Weight
     37 	}
     38 
     39 	return units.KilogramToPounds(u.Weight)
     40 }