timex

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: MIT Imports: 1 Imported by: 13

Documentation

Index

Constants

View Source
const (
	OneMinSec  = 60
	OneHourSec = 3600
	OneDaySec  = 86400
	OneWeekSec = 7 * 86400

	OneMin  = time.Minute
	OneHour = time.Hour
	OneDay  = 24 * time.Hour
	OneWeek = 7 * 24 * time.Hour
)

Variables

View Source
var (
	// DefaultLayout template for format time
	DefaultLayout = "2006-01-02 15:04:05"
)

Functions

func AddDay

func AddDay(t time.Time, day int) time.Time

AddDay add some day time for given time

func AddHour

func AddHour(t time.Time, hour int) time.Time

AddHour add some hour time for given time

func AddMinutes

func AddMinutes(t time.Time, minutes int) time.Time

AddMinutes add some minutes time for given time

func AddSeconds

func AddSeconds(t time.Time, seconds int) time.Time

AddSeconds add some seconds time for given time

func Format

func Format(t time.Time) string

Format use default layout

func FormatBy

func FormatBy(t time.Time, layout string) string

FormatBy given default layout

func FormatUnix

func FormatUnix(sec int64) string

FormatUnix time seconds use default layout

func FormatUnixBy

func FormatUnixBy(sec int64, layout string) string

FormatUnixBy format time seconds use given layout

func NowAddDay

func NowAddDay(day int) time.Time

NowAddDay add some day time from now

func NowAddHour

func NowAddHour(hour int) time.Time

NowAddHour add some hour time from now

func NowAddMinutes

func NowAddMinutes(minutes int) time.Time

NowAddMinutes add some minutes time from now

func NowAddSeconds

func NowAddSeconds(seconds int) time.Time

NowAddSeconds add some seconds time from now

func NowUnix

func NowUnix() int64

NowUnix is short of time.Now().Unix()

func SetLocalByName

func SetLocalByName(tzName string) error

SetLocalByName tz name. eg: UTC, PRC

Types

type TimeX

type TimeX struct {
	time.Time
	// DateLayout set the default date format layout. default use DefaultLayout
	DateLayout string
}

TimeX struct

func Local

func Local() TimeX

Local time for now

func LocalByName

func LocalByName(tzName string) TimeX

LocalByName time for now

func Now

func Now() TimeX

Now time

func (*TimeX) AddDay

func (t *TimeX) AddDay(day int) TimeX

AddDay add some day time for the time

func (*TimeX) AddHour

func (t *TimeX) AddHour(hours int) TimeX

AddHour add some hour time

func (*TimeX) AddMinutes

func (t *TimeX) AddMinutes(minutes int) TimeX

AddMinutes add some minutes time for the time

func (*TimeX) AddSeconds

func (t *TimeX) AddSeconds(seconds int) TimeX

AddSeconds add some seconds time the time

func (*TimeX) Datetime

func (t *TimeX) Datetime() string

Datetime use DefaultLayout format time to date

Jump to

Keyboard shortcuts

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