Skip to content

Commit

Permalink
Add Subtract for Times
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan Wei authored and Allan Wei committed Oct 9, 2018
1 parent 2746616 commit 024137e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"go.inferGopath": false
}
15 changes: 15 additions & 0 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,18 @@ func Strings(input []string) []string {
}
return u
}

//Subtract ...
func Subtract(endtime, starttime string) (Duration *time.Duration, err error) {
s, err := time.Parse(starttime, starttime)
if err != nil {
return nil, err
}
e, err := time.Parse(endtime, endtime)
if err != nil {
return nil, err
}
d := e.Sub(s)
return &d, nil

}

0 comments on commit 024137e

Please sign in to comment.