Package krtime provides helper functions that ease to use time.Time in Korea.
No more seoul, err := time.LoadLocation("Asia/Seoul"); if err != nil { ... }; t := time.Now().In(seoul)
.
So much boilerplate code is required when you want to display or manipulate time in KST.
seoul, err := time.LoadLocation("Asia/Seoul")
if err != nil {
panic(fmt.Errorf("load location %q: %v", "Asia/Seoul", err))
}
now := time.Now().In(seoul)
No fun. Too verbose. Can't remember timezone string.
Run go get github.com/getogrand/krtime
.
import "github.com/getogrand/krtime"
now := krtime.Now()
import "time"
import "github.com/getogrand/krtime"
someTime := time.Now().After(1 * time.Hour)
nowkr := krtime.New(someTime) // It returns pure time.Time
Work With jinzhu's now Package
import "github.com/jinzhu/now"
import "github.com/getogrand/krtime"
todayEnd := now.New(krtime.Now()).EndOfDay()
import "github.com/jinzhu/now"
import "github.com/cactus/gostrftime"
import "github.com/getogrand/krtime"
todayEnd := now.New(krtime.Now()).EndOfDay()
timestr := gostrftime.Format("%m월 %d일 %l시%M분 %p", krtime.New(todayEnd))
Extracted From heybeauty
Released under the MIT License