timeutil

package
v0.0.0-...-495e01f Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DateTime

func DateTime(format string, datetime any) template.HTML

DateTime renders an absolute time HTML element by datetime.

func GetExecutableModTime

func GetExecutableModTime() time.Time

GetExecutableModTime get executable file modified time of current process.

func Set

func Set(now time.Time)

Set sets the time to a mocked time.Time

func Unset

func Unset()

Unset will unset the mocked time.Time

Types

type TimeStamp

type TimeStamp int64

TimeStamp defines a timestamp

func TimeStampNow

func TimeStampNow() TimeStamp

TimeStampNow returns now int64

func (TimeStamp) Add

func (ts TimeStamp) Add(seconds int64) TimeStamp

Add adds seconds and return sum

func (TimeStamp) AddDuration

func (ts TimeStamp) AddDuration(interval time.Duration) TimeStamp

AddDuration adds time.Duration and return sum

func (TimeStamp) AsLocalTime

func (ts TimeStamp) AsLocalTime() time.Time

AsLocalTime convert timestamp as time.Time in local location

func (TimeStamp) AsTime

func (ts TimeStamp) AsTime() (tm time.Time)

AsTime convert timestamp as time.Time in Local locale

func (TimeStamp) AsTimeInLocation

func (ts TimeStamp) AsTimeInLocation(loc *time.Location) time.Time

AsTimeInLocation convert timestamp as time.Time in Local locale

func (TimeStamp) AsTimePtr

func (ts TimeStamp) AsTimePtr() *time.Time

AsTimePtr convert timestamp as *time.Time in Local locale

func (TimeStamp) AsTimePtrInLocation

func (ts TimeStamp) AsTimePtrInLocation(loc *time.Location) *time.Time

AsTimePtrInLocation convert timestamp as *time.Time in customize location

func (TimeStamp) Format

func (ts TimeStamp) Format(f string) string

Format formats timestamp as given format

func (TimeStamp) FormatDate

func (ts TimeStamp) FormatDate() string

FormatDate formats a date in YYYY-MM-DD server time zone

func (TimeStamp) FormatInLocation

func (ts TimeStamp) FormatInLocation(f string, loc *time.Location) string

FormatInLocation formats timestamp as given format with spiecific location

func (TimeStamp) FormatLong

func (ts TimeStamp) FormatLong() string

FormatLong formats as RFC1123Z

func (TimeStamp) FormatShort

func (ts TimeStamp) FormatShort() string

FormatShort formats as short

func (TimeStamp) IsZero

func (ts TimeStamp) IsZero() bool

IsZero is zero time

func (TimeStamp) Year

func (ts TimeStamp) Year() int

Year returns the time's year

type TimeStampNano

type TimeStampNano int64

TimeStampNano is for nano time in database, do not use it unless there is a real requirement.

func TimeStampNanoNow

func TimeStampNanoNow() TimeStampNano

TimeStampNanoNow returns now nano int64

func (TimeStampNano) AsTime

func (tsn TimeStampNano) AsTime() (tm time.Time)

AsTime convert timestamp as time.Time in Local locale

func (TimeStampNano) AsTimeInLocation

func (tsn TimeStampNano) AsTimeInLocation(loc *time.Location) time.Time

AsTimeInLocation convert timestamp as time.Time in Local locale

Jump to

Keyboard shortcuts

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