timeUtil

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DateFormat        = "2006-01-02"
	DateCompactFormat = "20060102"
	TimeFormat        = "2006-01-02 15:04:05"
	LongFormat        = "2006-01-02 15:04:05.999"
	CompactFormat     = "20060102150405" // 紧凑型格式
	AllFormat         = "2006-01-02 15:04:05.999999999 -0700 MST"
)

Variables

This section is empty.

Functions

func CalDay

func CalDay(t time.Time, n int) time.Time

func ChangeLoc

func ChangeLoc(t time.Time, target string) time.Time

func CompareDay

func CompareDay(t1, t2 time.Time) int

按天进行比较 小于:-1 大于:1 等于: 0

func Cp56time2aToTime

func Cp56time2aToTime(hexStr string) (time.Time, error)

func GetFirstDateOfMonth

func GetFirstDateOfMonth(d time.Time) time.Time

获取传入的时间所在月份的第一天,即某月第一天的0点。如传入time.Now(), 返回当前月份的第一天0点时间。

func GetLastDateOfMonth

func GetLastDateOfMonth(d time.Time) time.Time

获取传入的时间所在月份的最后一天,即某月最后一天的0点。如传入time.Now(), 返回当前月份的最后一天0点时间。

func GetZeroTime

func GetZeroTime(d time.Time) time.Time

获取某一天的0点时间

func NowFmtStr

func NowFmtStr(fmtStr string) string

func NowMillis

func NowMillis() int64

NowMillis 得到当前时间戳 毫秒

func NowNano

func NowNano() int64

func NowSecond

func NowSecond() int64

NowSecond 得到当前时间戳 秒

func NowStr

func NowStr() string

NowStr 得到当前时间的通用格式字符串

func NowStr2

func NowStr2() string

NowStr2 得到当前时间的字符串(秒)

func Parse

func Parse(str string) (time.Time, error)

func ParseWithFmt

func ParseWithFmt(fmt, str string) (time.Time, error)

func SetTimeZero

func SetTimeZero(t time.Time) time.Time

func TimeFmtStr

func TimeFmtStr(t time.Time, fmt string) string

func TimeFromStamp

func TimeFromStamp(s, ns int64) time.Time

TimeFromStamp 时间戳 参数 s 为秒 ns 为纳秒 注:最后的时间为s+ns的结果 millis := nanos / 1000000 // 毫秒

func TimeFromStampMillis

func TimeFromStampMillis(ms int64) time.Time

func TimeMillis

func TimeMillis(t time.Time) int64

func TimeNano

func TimeNano(t time.Time) int64

func TimeSecond

func TimeSecond(t time.Time) int64

func TimeStr

func TimeStr(t time.Time) string

func TimeToCp56time2a

func TimeToCp56time2a(t time.Time) string

func Tomorrow

func Tomorrow() time.Time

func UTCbyTime

func UTCbyTime(t time.Time) (time.Time, error)

func Yesterday

func Yesterday() time.Time

Types

type Time

type Time time.Time

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (Time) String

func (t Time) String() string

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

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