timeutil

package
v1.15.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2021 License: MIT Imports: 7 Imported by: 60

Documentation

Index

Constants

View Source
const (
	Minute = 60
	Hour   = 60 * Minute
	Day    = 24 * Hour
	Week   = 7 * Day
	Month  = 30 * Day
	Year   = 12 * Month
)

Seconds-based time units

Variables

This section is empty.

Functions

func GetLangTimeFormat

func GetLangTimeFormat(lang string) string

GetLangTimeFormat represents the default time format for the language

func GetTimeFormat

func GetTimeFormat(lang string) string

GetTimeFormat represents the

func MinutesToFriendly

func MinutesToFriendly(minutes int, lang string) string

MinutesToFriendly returns a user friendly string with number of minutes converted to hours and minutes.

func RawTimeSince

func RawTimeSince(t time.Time, lang string) string

RawTimeSince retrieves i18n key of time since t

func TimeSince

func TimeSince(then time.Time, lang string) template.HTML

TimeSince calculates the time interval and generate user-friendly string.

func TimeSincePro

func TimeSincePro(then time.Time, lang string) string

TimeSincePro calculates the time interval and generate full user-friendly string.

func TimeSinceUnix

func TimeSinceUnix(then TimeStamp, lang string) template.HTML

TimeSinceUnix calculates the time interval and generate user-friendly string.

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) 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) (tm 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 added in v1.12.0

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

Jump to

Keyboard shortcuts

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