Skip to content

Instantly share code, notes, and snippets.

@oem
Created January 22, 2016 23:09
Show Gist options
  • Save oem/f0fef51c45c44d899c77 to your computer and use it in GitHub Desktop.
Save oem/f0fef51c45c44d899c77 to your computer and use it in GitHub Desktop.
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