Booking up for Beauty

Two tasks are failing one test case each. Would appreciate if someone could review the code and tell me where I went wrong -

// HasPassed returns whether a date has passed.
func HasPassed(date string) bool {
checkTime, _ := time.Parse(“July 25, 2019 13:45:00”, date)
return checkTime.Before(time.Now())
}

booking_up_for_beauty_test.go:38: HasPassed(December 9, 2112 11:59:59) = ‘true’, want ‘false’

// IsAfternoonAppointment returns whether a time is in the afternoon.
func IsAfternoonAppointment(date string) bool {
aptTime, _ := time.Parse(“Thursday, July 25, 2019 13:45:00”, date)
hour := aptTime.Hour()
return hour >= 12 && hour < 18
}

booking_up_for_beauty_test.go:56: IsAfternoonAppointment(Friday, March 8, 1974 12:02:02) = ‘false’, want ‘true’

Parsing datetime strings in Go is weird. The layout string has to have specific values:

  1. month = 1 or Jan or January
  2. day = 2
    • day of week = “Mon” or “Monday”
  3. hour = 3 or 15
    • am/pm = “PM”
  4. minute = 4
  5. second = 5
  6. year = 2006
  7. TZ offset = -0700

So, they layout for HasPassed must be

"January 2, 2006 15:04:05"

Refs:

Yes, changing the layout format worked. Thanks for your help.