utils

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToString

func BytesToString(bytes []byte) string

func Hash64

func Hash64(str []byte) int64

func JSONString

func JSONString(data interface{}) string

func Md5ToString

func Md5ToString(str string) string

func PrintJSON

func PrintJSON(obj interface{}) string

PrintJSON prints any interface to json string in cmd

func Remove

func Remove(s []string, r string) []string

func StructToJSONBytes

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

StructToJSONBytes 把数据转成json的bytes

func StructToJSONString

func StructToJSONString(data interface{}) (string, error)

func StructToPrettyJSONString

func StructToPrettyJSONString(data interface{}) (string, error)

Types

type UltipaTime

type UltipaTime struct {
	Datetime uint64
	Year     uint64
	Month    uint64
	Day      uint64
	Hour     uint64
	Minute   uint64
	Second   uint64
	Macrosec uint64
	Time     *time.Time
}

func (*UltipaTime) New

func (t *UltipaTime) New(datetime uint64) *UltipaTime

func (*UltipaTime) NewFromString

func (u *UltipaTime) NewFromString(dateString string) (*UltipaTime, error)

StringToTime , layoutISO := "2006-01-02 15:04:05.000" StringToTime , layoutISO := "2006-01-02 15:04:05" StringToTime , layoutISO := "2006-01-02"

func (*UltipaTime) TimeToUint64

func (u *UltipaTime) TimeToUint64(time *time.Time) uint64

uint64_t datetime = 0; uint64_t year_month = year * 13 + month; datetime |= (year_month << 46); datetime |= (day << 41); datetime |= (hour << 36); datetime |= (minute << 30); datetime |= (second << 24); datetime |= macrosec;

func (*UltipaTime) ToString

func (u *UltipaTime) ToString() string

func (*UltipaTime) Uint64ToTime

func (t *UltipaTime) Uint64ToTime(datetime uint64) (_t *time.Time)

uint64_t year = 0; uint64_t month = 0; uint64_t day = 0; uint64_t hour = 0; uint64_t minute = 0; uint64_t second = 0; uint64_t macrosec = 0;

if (year > 70 && year < 100) { year += 1900; } else if (year < 70) { year += 2000; }

Jump to

Keyboard shortcuts

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