Created
January 22, 2016 23:09
-
-
Save oem/f0fef51c45c44d899c77 to your computer and use it in GitHub Desktop.
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" | |
) | |
const timeFormat = "2006-01-02 15:04 MST" | |
func main() { | |
goingHome, err := time.Parse(timeFormat, "2016-04-01 12:00 UTC") | |
if err != nil { | |
fmt.Println(err) | |
return | |
} | |
delta := goingHome.Sub(time.Now()) | |
daysUntil := int(delta.Hours() / 24) | |
fmt.Printf("%v days until home\n", daysUntil) | |
fmt.Printf("%v weeks until home\n", daysUntil/7) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment