Created
January 12, 2017 21:14
-
-
Save aeppert/5b2eba9e966f418e15fbc807bbf757db to your computer and use it in GitHub Desktop.
Return the time.Time between passed in time and duration string (m,h,s, etc.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| ) | |
| func getDurationDiff(t time.Time, duration string) (time.Time, error) { | |
| dur, err := time.ParseDuration(fmt.Sprintf("-%s", duration)) | |
| if err != nil { | |
| return time.Now(), err | |
| } | |
| then := t.Add(dur) | |
| return then, nil | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment