Skip to content

Instantly share code, notes, and snippets.

@cakesmith
Last active November 18, 2016 16:47
Show Gist options
  • Save cakesmith/57af51c332876e2968fdef6332f5e337 to your computer and use it in GitHub Desktop.
Save cakesmith/57af51c332876e2968fdef6332f5e337 to your computer and use it in GitHub Desktop.
loc, _ := time.LoadLocation("America/New_York")
longForm := "January 02 2006 03:04 pm"
year, month, day := time.Now().Date()
todayAt, err := time.ParseInLocation(longForm, fmt.Sprintf("%v %v %v %v", month, day, year, timeInput), loc)
if err != nil {
fmt.Printf("Error parsing time: %s\n", err.Error())
s.User.SendString(fmt.Sprintf(timeTroubleF, timeInput))
return
}
inThePast := todayAt.Before(inEst(time.Now()))
oneHourAgo := time.Now().Add(-1*time.Hour).In(loc).Format("03:04 PM")
oneHourFromNow := time.Now().Add(1*time.Hour).In(loc).Format("03:04 PM")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment