mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Cleaner pretty dates
This commit is contained in:
committed by
Chris Cummer
parent
59676ca344
commit
a82db2bea8
@@ -7,6 +7,9 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// DateFormat defines the format we expect to receive dates from BambooHR in
|
||||
const DateFormat = "2006-01-02"
|
||||
|
||||
func CenterText(str string, width int) string {
|
||||
return fmt.Sprintf("%[1]*s", -width, fmt.Sprintf("%[1]*s", (width+len(str))/2, str))
|
||||
}
|
||||
@@ -31,6 +34,11 @@ func ExecuteCommand(cmd *exec.Cmd) string {
|
||||
return str
|
||||
}
|
||||
|
||||
func PrettyDate(dateStr string) string {
|
||||
newTime, _ := time.Parse(DateFormat, dateStr)
|
||||
return fmt.Sprint(newTime.Format("Jan 2, 2006"))
|
||||
}
|
||||
|
||||
func Today() string {
|
||||
localNow := time.Now().Local()
|
||||
return localNow.Format("2006-01-02")
|
||||
|
||||
Reference in New Issue
Block a user