Skip to content

WindomZ/timezh

Repository files navigation

timezh - Chinese style time

Golang库 - 时间格式中文化

Build Status Coverage Status GoDoc Go Report Card

扩展原生time快速实现时间格式中文化

Install

go get github.com/WindomZ/timezh

Roadmap

  • Format
    • Format(string) string
    • FormatMix(string) string
    • FormatLayout(string) string
    • FormatValue(string) string
  • Parse
    • Parse(string, string) (Time, error)
    • ParseLayout(string) string
    • ParseValue(string) string

Usage

格式用途 原生time 引入timezh
月份 January, Jan 一月
星期 Monday, Mon 星期一, 周一
上下午 PM, pm 下午

time不支持中文化:

import "time"

time.Now().Format("2006年01月02日(January) PM3:04:05 Monday(Mon)")

>>> 2009年01月03日(January) PM6:15:05 Saturday(Sat)

timezh支持中文化:

import "github.com/WindomZ/timezh"

timezh.Now().Format("2006年01月02日(一月) 下午3:04:05 星期一(周一)")

>>> 2009年01月03日(一月) 下午6:15:05 星期六(周六)

timezh支持中文解析:

import "github.com/WindomZ/timezh"

timezh.Parse("2006年01月02日(一月) 下午3:04:05 星期一(周一)", "2009年01月03日(一月) 下午6:15:05 星期六(周六)")

time.Now().Format("2006年01月02日(January) PM3:04:05 Monday(Mon)")
timezh.Now().Format("2006年01月02日(一月) 下午3:04:05 星期一(周一)")

>>> 2009年01月03日(January) PM6:15:05 Saturday(Sat)
>>> 2009年01月03日(一月) 下午6:15:05 星期六(周六)

Advanced

混杂中英文:

import "github.com/WindomZ/timezh"

timezh.Now().FormatMix("2006年01月02日(January, 一月) 下午3:04:05PM 星期一(Mon, 周一)")

>>> 2009年01月03日(January, 一月) 下午6:15:05PM 星期六(Sat, 周六)

文本中文化:

import "github.com/WindomZ/timezh"

timezh.FormatValue("2009年01月03日(January) 6:15:05PM 星期六(Sat)")

>>> 2009年01月03日(一月) 6:15:05下午 星期六(周六)

文本中文解析:

import "github.com/WindomZ/timezh"

timezh.ParseValue("2009年01月03日(一月) 6:15:05下午 星期六(周六)")

>>> 2009年01月03日(Jan) 6:15:05PM Saturday(Sat)

Benchmark

详见BENCHMARK

Contributing

欢迎你Fork,提交PR,在issues page汇报Bugs、提出新想法等, 我很乐意能一起参与。

如果你喜欢这个项目,可以点下 ⭐ 予以支持,谢谢!

许可

MIT

About

Golang库 - 时间格式中文化(Chinese style time)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages