Getting Date Ranges in Go

Getting some date ranges

// Get the start and end dates of the current month
func GetMonthDay(types int) (string, string) {
    now := time.Now()
    currentYear, currentMonth, _ := now.Date()
    currentLocation := now.Location()

    firstOfMonth := time.Date(currentYear, currentMonth, 1, 0, 0, 0, 0, currentLocation)
    lastOfMonth := firstOfMonth.AddDate(0, 1, -1)
    f := firstOfMonth.Unix()
    l := lastOfMonth.Unix()
    if types == 1 {
        return time.Unix(f, 0).Format("2006-01-02"), time.Unix(l, 0).Format("2006-01-02")
    }
    return time.Unix(f, 0).Format("2006-01-02") + " 00:00:00", time.Unix(l, 0).Format("2006-01-02") + " 23:59:59"
}
// Get the start and end time of the current week
func GetWeekDay(types int) (string, string) {
    now := time.Now()
    offset := int(time.Monday - now.Weekday())
    // Special handling for Sunday because time.Monday = 0
    if offset > 0 {
        offset = -6
    }

    lastoffset := int(time.Saturday - now.Weekday())
    // Special handling for Sunday because time.Monday = 0
    if lastoffset == 6 {
        lastoffset = -1
    }

    firstOfWeek := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset)
    lastOfWeeK := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, lastoffset+1)
    f := firstOfWeek.Unix()
    l := lastOfWeeK.Unix()
    if types == 1 {
        return time.Unix(f, 0).Format("2006-01-02"), time.Unix(l, 0).Format("2006-01-02")
    }
    return time.Unix(f, 0).Format("2006-01-02") + " 00:00:00", time.Unix(l, 0).Format("2006-01-02") + " 23:59:59"
}

// Get the start and end dates of the current quarter
func GetQuarterDay() (string, string) {
    year := time.Now().Format("2006")
    month := int(time.Now().Month())
    var firstOfQuarter string
    var lastOfQuarter string
    if month >= 1 && month <= 3 {
        // January 1st
        firstOfQuarter = year + "-01-01 00:00:00"
        lastOfQuarter = year + "-03-31 23:59:59"
    } else if month >= 4 && month <= 6 {
        firstOfQuarter = year + "-04-01 00:00:00"
        lastOfQuarter = year + "-06-30 23:59:59"
    } else if month >= 7 && month <= 9 {
        firstOfQuarter = year + "-07-01 00:00:00"
        lastOfQuarter = year + "-09-30 23:59:59"
    } else {
        firstOfQuarter = year + "-10-01 00:00:00"
        lastOfQuarter = year + "-12-31 23:59:59"
    }
    return firstOfQuarter, lastOfQuarter
}

// Take a start date and an end date and work out every date in between
func GetBetweenDates(sdate, edate string) []string {
    d := []string{}
    timeFormatTpl := "2006-01-02 15:04:05"
    if len(timeFormatTpl) != len(sdate) {
        timeFormatTpl = timeFormatTpl[0:len(sdate)]
    }
    date, err := time.Parse(timeFormatTpl, sdate)
    if err != nil {
        // time parse error
        return d
    }
    date2, err := time.Parse(timeFormatTpl, edate)
    if err != nil {
        // time parse error
        return d
    }
    if date2.Before(date) {
        // error if the end time is earlier than the start time
        return d
    }
    // the output date format is fixed
    timeFormatTpl = "2006-01-02"
    date2Str := date2.Format(timeFormatTpl)
    d = append(d, date.Format(timeFormatTpl))
    for {
        date = date.AddDate(0, 0, 1)
        dateStr := date.Format(timeFormatTpl)
        d = append(d, dateStr)
        if dateStr == date2Str {
            break
        }
    }
    return d
}

var timeFormatTemplate = "2006-01-02 15:04:05"

// GetDate returns the current date
func GetDate() string {
    return time.Now().Format(timeFormatTemplate)
}

// GetStampToDate converts a timestamp to a date
func GetStampToDate(TimeStamp int64) string {
    return time.Unix(TimeStamp, 0).Format(timeFormatTemplate)
}

// GetSubDate dynamically shifts the date by a number of days forward or back
func GetSubDate(Year, Month, Date int) string {
    return time.Now().AddDate(Year, Month, Date).Format("2006-01-02")
}

func GetDateToTimeStamp(Date string) int64 {
    stamp, _ := time.ParseInLocation(timeFormatTemplate, Date, time.Local)
    return stamp.Unix()
}

// Format a time after specifying the time format
func DataToData(dataType string, data string) string {
    time, _ := time.Parse(dataType, data)
    return GetStampToDate(time.Unix())
}