github.com/wtfutil/wtf@v0.43.0/modules/football/util.go (about)

     1  package football
     2  
     3  import (
     4  	"bytes"
     5  	"fmt"
     6  	"strings"
     7  	"time"
     8  
     9  	"github.com/olekukonko/tablewriter"
    10  )
    11  
    12  func createTable(header []string, buf *bytes.Buffer) *tablewriter.Table {
    13  
    14  	table := tablewriter.NewWriter(buf)
    15  	if len(header) != 0 {
    16  		table.SetHeader(header)
    17  	}
    18  	table.SetBorder(false)
    19  	table.SetCenterSeparator(" ")
    20  	table.SetColumnSeparator(" ")
    21  	table.SetRowSeparator(" ")
    22  	table.SetAlignment(tablewriter.ALIGN_LEFT)
    23  
    24  	return table
    25  }
    26  
    27  func parseDateString(d string) string {
    28  
    29  	return fmt.Sprintf("🕙 %s", strings.Replace(d, "T", " ", 1))
    30  }
    31  
    32  func getDateString(offset int) string {
    33  
    34  	today := time.Now()
    35  	return today.AddDate(0, 0, offset).Format("2006-01-02")
    36  
    37  }