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" //EST
yesterday := tareekh.Yesterday()
fmt.Println(yesterday) //yesterdays time object
dt, 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-22
future := time.Now().AddDate(0, 0, 1)
isit := tareekh.IsDateInFuture(future)
fmt.Println(isit) //should be true
begin := tareekh.BeginningOfMonth() //first of current month
end := tareekh.EndOfMonth() //last day of current month
dayx := tareekh.FromDayOfMonth(1) //specified day of current month
In development, if there's other useful stuff feel free to fork and issue a pull request.