1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/wtf/datetime.go
2018-06-23 14:06:28 -07:00

36 lines
656 B
Go

package wtf
import (
"fmt"
"time"
)
// DateFormat defines the format we expect to receive dates from BambooHR in
const DateFormat = "2006-01-02"
const TimeFormat = "15:04"
func IsToday(date time.Time) bool {
now := Now()
return (date.Year() == now.Year()) &&
(date.Month() == now.Month()) &&
(date.Day() == now.Day())
}
func Now() time.Time {
return time.Now().Local()
}
func PrettyDate(dateStr string) string {
newTime, _ := time.Parse(DateFormat, dateStr)
return fmt.Sprint(newTime.Format("Jan 2, 2006"))
}
func Tomorrow() time.Time {
return Now().AddDate(0, 0, 1)
}
func UnixTime(unix int64) time.Time {
return time.Unix(unix, 0)
}