timetool

package
v0.0.53 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DateLayout     = "2006-01-02"
	TimeLayout     = "15:04:05"
	DateTimeLayout = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

func DateFromNow

func DateFromNow() string

現在時間 格式為"2006-01-02"

func DateFromTimeStamp

func DateFromTimeStamp(timestamp int64) string

透過time.Now().Unix()出來的秒數轉為 "2006-01-02"

func DateTimeFromNow

func DateTimeFromNow() string

現在時間 格式為"2006-01-02 15:04:05"

func DateTimeFromTimeStamp

func DateTimeFromTimeStamp(timestamp int64) (string, string)

透過time.Now().Unix()出來的秒數轉為 "2006-01-02" "15:04:05"

func GetBetweenDates

func GetBetweenDates(start string, end string) []string

func GetBetweenTimes

func GetBetweenTimes(start string, end string) []string

func GetDurationUntil added in v0.0.39

func GetDurationUntil(targetTime time.Time) int

GetDurationUntil -取得到指定時間的時間差(秒)

func GetDurationUntilMidnight added in v0.0.39

func GetDurationUntilMidnight() int

GetDurationUntilMidnight -取得到當日0點的時間差(秒)

func GetDurationUntilNextMonth added in v0.0.39

func GetDurationUntilNextMonth() int

GetDurationUntilNextMonth -取得到次月1日0點的時間差(秒)

func GetWeek

func GetWeek() (y, w int)

透過time.Now()出來的年份跟週數

func TimeFromNow

func TimeFromNow() string

現在時間 格式為"15:04:05"

func TimeFromTimeStamp

func TimeFromTimeStamp(timestamp int64) string

透過time.Now().Unix()出來的秒數轉為 "15:04:05"

func TimeNowStr

func TimeNowStr() string

TimeNowStr 輸出格式為 2019/11/4 20:15:26

func TimeStamptoDateTime

func TimeStamptoDateTime(timestamp int64) string
轉化成"2006-01-02 15:04:05"的時間模版

輸入為time.Now().Unix()

func TimestrToTimestamp

func TimestrToTimestamp(time_str string, flag int) int64

日期格式轉時間戳

Types

type Ticker

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

Ticker 定義一個Ticker,用於時間控制

type TickerManager

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

TickerManager 封裝一個tick的管理類,避免每次都要寫一大堆

func GetTickManager

func GetTickManager() *TickerManager

GetTickManager 得到tickmanage

func (*TickerManager) ClearTicker

func (tm *TickerManager) ClearTicker(id uint64)

ClearTicker 清除tick, 停止tick

func (*TickerManager) DelayExec

func (tm *TickerManager) DelayExec(callback func(), d time.Duration) uint64

DelayExec 延遲執行函數

func (*TickerManager) Init

func (tm *TickerManager) Init()

Init 初始化tickermanager, 就是設置起始id

Jump to

Keyboard shortcuts

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