Tareekh is a GoLang library to make it a little bit easy to work with dates. This was written to avoid reimplementing common functionality working with time.Time.
By default the Local timezone is used. But if you want to specify a particular timezone, just do:
tareekh.TimeZone = "America/New_York" //ESTyesterday := tareekh.Yesterday()
fmt.Println(yesterday) //yesterdays time objectdt, err := tareekh.FromDateString("2016-11-22")
if err != nil {
//handle error
}
fmt.Println(t)t, _ := tareekh.FromDateString("2016-11-22")
shortDate := tareekh.ToShortDate(t)
fmt.Println(shortDate) //should print 2016-11-22future := time.Now().AddDate(0, 0, 1)
isit := tareekh.IsDateInFuture(future)
fmt.Println(isit) //should be truebegin := tareekh.BeginningOfMonth() //first of current monthend := tareekh.EndOfMonth() //last day of current monthdayx := tareekh.FromDayOfMonth(1) //specified day of current monthIn development, if there's other useful stuff feel free to fork and issue a pull request.