Skip to content

Helper functions that ease to use time.Time in Korea.

License

Notifications You must be signed in to change notification settings

getogrand/krtime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

krtime

GoDoc Build Status

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).

Why should use this package?

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.

Installation

Run go get github.com/getogrand/krtime.

Usage

Get Current Time as KST

import "github.com/getogrand/krtime"

now := krtime.Now()

Convert a Time to KST Time

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()

Work With Any Other Libraries Compatible With time.Time

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

License

Released under the MIT License

About

Helper functions that ease to use time.Time in Korea.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages