tool

package
v0.0.0-...-41c389d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ShanghaiLocationOffset 是东八区的 offset
	ShanghaiLocationOffset = 8 * 60 * 60
	// ShanghaiLocation 表示东八区
	ShanghaiLocation = time.FixedZone("Asia/Shanghai", 8*60*60)
)

Functions

func B2D

func B2D(b []byte, data interface{}) error

B2D bytes to struct

func B2I

func B2I(b []byte) int

B2I bytes to int

func B2S

func B2S(b []byte) string

B2S bytes to string

func BeginningOfDay

func BeginningOfDay(t time.Time, locationOffsetSeconds int) time.Time

BeginningOfDay 获取 t 这个时间点所在天的零点时间.

返回的 time.Time 和传入的参数 t 的 *time.Location 一致!

func BeginningOfHour

func BeginningOfHour(t time.Time, locationOffsetSeconds int) time.Time

BeginningOfHour 获取 t 这个时间点所在小时的开始时间.

返回的 time.Time 和传入的参数 t 的 *time.Location 一致!

func BeginningOfMonth

func BeginningOfMonth(t time.Time, loc *time.Location) time.Time

BeginningOfMonth 获取 t 这个时间点所在 month 的零点时间.

返回的 time.Time 和传入的参数 t 的 *time.Location 一致!

func BeginningOfNextMonth

func BeginningOfNextMonth(t time.Time, loc *time.Location) time.Time

BeginningOfNextMonth 获取 t 这个时间点的下一个 month 的零点时间.

返回的 time.Time 和传入的参数 t 的 *time.Location 一致!

func BeginningOfNextYear

func BeginningOfNextYear(t time.Time, loc *time.Location) time.Time

BeginningOfNextYear 获取 t 这个时间点的下一个 year 的零点时间.

返回的 time.Time 和传入的参数 t 的 *time.Location 一致!

func BeginningOfYear

func BeginningOfYear(t time.Time, loc *time.Location) time.Time

BeginningOfYear 获取 t 这个时间点所在 year 的零点时间.

返回的 time.Time 和传入的参数 t 的 *time.Location 一致!

func CompressStr

func CompressStr(str string) string

CompressStr remove blank character

func D2B

func D2B(data interface{}) []byte

D2B struct to bytes

func D2S

func D2S(data interface{}) (r string)

D2S struct to string

func GbkToUtf8

func GbkToUtf8(s []byte) ([]byte, error)

GbkToUtf8 gbk To utf-8

func I2B

func I2B(n int) []byte

I2B int to bytes

func Md5

func Md5(msg string) string

Md5 cz

func MondayOfWeek

func MondayOfWeek(t time.Time, locationOffsetSeconds int) time.Time

MondayOfWeek 获取 t 这个时间点所在星期的星期一(Monday)的零点时间.

返回的 time.Time 和传入的参数 t 的 *time.Location 一致!

func S2B

func S2B(s string) []byte

S2B string to bytes

func TimeSubDay

func TimeSubDay(t1, t2 time.Time) int

TimeSubDay time sub time return days

func TimeSubHour

func TimeSubHour(t1, t2 time.Time) int

TimeSubHour time sub time return hours

func TimeSubWeek

func TimeSubWeek(t1, t2 time.Time, switchDay time.Weekday) int

TimeSubWeek time sub time return weeks

func Utf8ToGbk

func Utf8ToGbk(s []byte) ([]byte, error)

Utf8ToGbk utf-8 to gbk

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL