Skip to content

Commit

Permalink
Add TimeDurationToHHMMString
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan Wei authored and Allan Wei committed Oct 22, 2018
1 parent 072192a commit 9ce2d85
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,18 @@ func StrutForScan(u interface{}, columns []string) []interface{} {

return v
}

//TimeDurationToHHMMString ...
func TimeDurationToHHMMString(duration float64, unit string) (rect string) {
s := fmt.Sprintf("%fm", duration)
h, err := time.ParseDuration(s)
if err != nil {
return
}
sdate := "2016-01-02T00:00:00Z"
t, _ := TimeParseRFC3339(sdate)
a := t.Add(h)
so := a.Format(time.RFC3339)
rect = so[11:15]
return
}

0 comments on commit 9ce2d85

Please sign in to comment.