func calculateDurUnits(dur time.Duration, durArray []interface{}, durUnitSlice []durationUnit) {
	remainingDur := dur
	durCount := 0
	for _, d := range durUnitSlice {
		if d.Present {
			durArray[durCount] = remainingDur / d.DurDivisor
			remainingDur = remainingDur % d.DurDivisor
			durCount++
		}
	}
}
calculateDurUnits takes a duration and breaks it up into its constituent
duration unit values.
package durationfmt
import (
	"fmt"
	"time"
)
const Day = 24 * time.Hour
const Week = 7 * Day
const Year = 365 * Day
type durationUnit struct {
	Present    bool
	DurDivisor time.Duration
}
func Format(dur time.Duration, fmtStr string) (string, error) {
	var durUnitSlice = []durationUnit{
		durationUnit{
			DurDivisor: Year,
		},
		durationUnit{
			DurDivisor: Week,
		},
		durationUnit{
			DurDivisor: Day,
		},
		durationUnit{
			DurDivisor: time.Hour,
		},
		durationUnit{
			DurDivisor: time.Minute,
		},
		durationUnit{
			DurDivisor: time.Second,
		},
	}
	var durUnitMap = map[string]*durationUnit{
		"y": &durUnitSlice[0],
		"w": &durUnitSlice[1],
		"d": &durUnitSlice[2],
		"h": &durUnitSlice[3],
		"m": &durUnitSlice[4],
		"s": &durUnitSlice[5],
	}
	sprintfFmt, durCount, err := parseFmtStr(fmtStr, durUnitMap)
	if err != nil {
		return "", err
	}
	durArray := make([]interface{}, durCount)
	calculateDurUnits(dur, durArray, durUnitSlice)
	return fmt.Sprintf(sprintfFmt, durArray...), nil
}