29 lines
431 B
Go
29 lines
431 B
Go
package intimate
|
|
|
|
import (
|
|
"log"
|
|
"time"
|
|
)
|
|
|
|
var zeroTime time.Time
|
|
|
|
func init() {
|
|
|
|
tm, err := time.Parse("15:04:05", "0:00:00")
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
zeroTime = tm
|
|
|
|
}
|
|
|
|
// ParseDuration time to duration eg: 1:40:00 -> time.Duration
|
|
func ParseDuration(dt string) (time.Duration, error) {
|
|
tdt, err := time.Parse("15:04:05", dt)
|
|
if err != nil {
|
|
|
|
return time.Duration(0), err
|
|
}
|
|
return tdt.Sub(zeroTime), nil
|
|
}
|