ztime

package
v1.7.12 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 7 Imported by: 5

Documentation

Overview

Package ztime provides time related operations

Index

Constants

This section is empty.

Variables

View Source
var (
	TimeTpl = "2006-01-02 15:04:05"

	GetLocationName = func(zone int) string {
		switch zone {
		case 8:
			return "Asia/Shanghai"
		}
		return "UTC"
	}
)

Functions

func Clock added in v1.4.6

func Clock() int64

Clock The current microsecond timestamp has an accuracy of 100ms

func FormatTime

func FormatTime(t time.Time, format ...string) string

FormatTime format time

func FormatTimestamp

func FormatTimestamp(timestamp int64, format ...string) string

FormatTimestamp format timestamp

func FormatTlp

func FormatTlp(format string) string

FormatTlp format template

func GetTimeZone

func GetTimeZone() *time.Location

GetTimeZone getTimeZone

func In added in v1.4.3

func In(tt time.Time) time.Time

In time to time

func MonthRange

func MonthRange(year int, month int) (beginTime, endTime int64, err error)

func Now added in v0.0.25

func Now(format ...string) string

Now format current time

func Parse added in v0.0.23

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

Parse string to time

func Time added in v1.4.5

func Time() time.Time

Time With the time zone of the time

func Unix added in v1.2.0

func Unix(tt int64) time.Time

Unix int to time

func UnixMicro added in v1.4.6

func UnixMicro(tt int64) time.Time

UnixMicro int to time

func Week

func Week(t time.Time) int

func Zone

func Zone(zone ...int) *time.Location

Zone eastEightTimeZone

Types

type TimeEngine

type TimeEngine struct {
	// contains filtered or unexported fields
}

func New

func New(zone ...int) *TimeEngine

New new timeEngine

func SetTimeZone

func SetTimeZone(zone int) *TimeEngine

SetTimeZone SetTimeZone

func (*TimeEngine) FormatTime

func (e *TimeEngine) FormatTime(t time.Time, format ...string) string

FormatTime string format of return time

func (*TimeEngine) FormatTimestamp

func (e *TimeEngine) FormatTimestamp(timestamp int64, format ...string) string

FormatTimestamp convert UNIX time to time string

func (*TimeEngine) GetTimeZone

func (e *TimeEngine) GetTimeZone() *time.Location

GetTimeZone GetTimeZone

func (*TimeEngine) In added in v1.4.3

func (e *TimeEngine) In(t time.Time) time.Time

func (*TimeEngine) MonthRange

func (e *TimeEngine) MonthRange(year int, month int) (beginTime, endTime int64, err error)

MonthRange gets the start and end UNIX times for the specified year and month

func (*TimeEngine) Parse

func (e *TimeEngine) Parse(str string, format ...string) (t time.Time, err error)

Parse Parse

func (*TimeEngine) SetTimeZone

func (e *TimeEngine) SetTimeZone(zone int) *TimeEngine

SetTimeZone SetTimeZone

func (*TimeEngine) Unix added in v1.2.0

func (e *TimeEngine) Unix(tt int64) time.Time

Unix int to time

func (*TimeEngine) UnixMicro added in v1.4.6

func (e *TimeEngine) UnixMicro(tt int64) time.Time

UnixMicro int to time

func (*TimeEngine) Week

func (e *TimeEngine) Week(t time.Time) int

Directories

Path Synopsis
Package cron emulate linux crontab
Package cron emulate linux crontab

Jump to

Keyboard shortcuts

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